ArrayList<ArrayList<String>> array = new ArrayList<ArrayList<String>>();
Depending on your requirements, you might use a Generic class like the one below to make access easier:
import java.util.ArrayList; class TwoDimentionalArrayList<T> extends ArrayList<ArrayList<T>> { public void addToInnerArray(int index, T element) { while (index >= this.size()) { this.add(new ArrayList<T>()); } this.get(index).add(element); } public void addToInnerArray(int index, int index2, T element) { while (index >= this.size()) { this.add(new ArrayList<T>()); } ArrayList<T> inner = this.get(index); while (index2 >= inner.size()) { inner.add(null); } inner.set(index2, element); } }
Related Posts:
- How to create an 2D ArrayList in java?
- How to avoid “ConcurrentModificationException” while removing elements from `ArrayList` while iterating it? [duplicate]
- When to use LinkedList over ArrayList in Java?
- Convert list to array in Java [duplicate]
- Initialization of an ArrayList in one line
- How to avoid java.util.ConcurrentModificationException when iterating through and removing elements from an ArrayList
- How to sort an ArrayList?
- What’s the C++ version of Java’s ArrayList
- Create ArrayList from array
- Best way to convert an ArrayList to a string
- “Exception in thread “main” java.lang.IndexOutOfBoundsException: Index: 0, Size: 0″ with ArrayList?
- Best way to convert an ArrayList to a string
- Print ArrayList
- Print ArrayList
- How to make a deep copy of Java ArrayList
- Array ArrayList python equivalent
- Java ArrayList copy
- how to iterate in List
- > in java and set their values as we do in a normal int a[i][j] matrix type [duplicate]
- How to convert an ArrayList containing Integers to primitive int array?
- Print ArrayList
- How do I do a deep copy of a 2d array in Java?
- Why do I get an UnsupportedOperationException when trying to remove an element from a List?
- HashSet vs. ArrayList
- Java ArrayList replace at specific index
- How can I create an Array of ArrayLists?
- Error: cannot find symbol ArrayList
- java howto ArrayList push, pop, shift, and unshift
- Java Comparator class to sort arrays
- How to get the last value of an ArrayList
- How to add an object to an ArrayList in Java
- Add String Array to ArrayList
- Incompatible types List of List and ArrayList of ArrayList
- Getting the array length of a 2D array in Java
- Size has private access in ArrayList
- How to write a test class to test my code?
- Create a two dimensional string array anArray[2][2]
- How to convert a String into an ArrayList?
- Java ArrayList of Doubles
- How to get rows and columns count of a 2D array in Java?
- convert string to arraylist
in java - What is the difference between ArrayList.clear() and ArrayList.removeAll()?
- Multidimensional Arrays lengths in Java
- ShoppingCart.Java Program Assignment
- How Do I Implement an Insertion Sort Method for A Generic ArrayList?
- toring and Retrieving ArrayList values from hashmap
- return an ArrayList method
- What’s the difference between map() and flatMap() methods in Java 8?
- Why do we need copy constructor and when should we use copy constructor in java
- What are the -Xms and -Xmx parameters when starting JVM?
- How to match “any character” in regular expression?
- Non-static variable cannot be referenced from a static context
- JAVA invalid maximum heap size. The specified size exceeds the maximum representable size
- JDK9: An illegal reflective access operation has occurred. org.python.core.PySystemState
- A long bigger than Long.MAX_VALUE
- Unreported exception java.lang.Exception; must be caught or declared to be thrown
- How to clear the console?
- How to capitalize the first letter of a String in Java?
- Scanner vs. BufferedReader
- Raw use of parameterized class
- :: (double colon) operator in Java 8
- What does ‘0’ do in Java?
- Service will not start: error 1067: the process terminated unexpectedly
- Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0 error in Java
- What’s the advantage of load() vs get() in Hibernate?
- What Java ORM do you prefer, and why?
- Always Round UP a Double
- Using Enum values as String literals
- How to change a package name in Eclipse?
- Are arrays passed by value or passed by reference in Java?
- How do I get “Press any key to continue” to work in my Java code?
- What does “?” mean in Java? [duplicate]
- What is the difference between a local variable, an instance field, an input parameter, and a class field?
- Could not find method compile() for arguments Gradle
- How can I get the current stack trace in Java?
- java.util.zip.ZipException: error in opening zip file
- paint() and repaint() in Java
- Good Hash Function for Strings
- Error – Illegal static declaration in inner class
- Bubble Sort Manually a Linked List in Java
- ArrayList<> cannot be resolved to a type
- Simple way to repeat a string
- Unreachable statement compile error in Java
- Reflection generic get field value
- error: incompatible types: char cannot be converted to String – Java
- mongoDB, connection refused
- Displaying Image in Java
- Invalid signature file digest for Manifest main attributes exception while trying to run jar file
- JAVA + try catch(FileNotFoundException e) going in catch(Exception e)?
- Using a do-while loop to check a User’s input in Java
- What is the proper annotation since @SpringApplicationConfiguration, @WebIntegration, is deprecated in Spring Boot Framework?
- How do I exit a while loop in Java?
- Java String import
- Is there a way to end the program if statement is false?
- ArithmeticException: “Non-terminating decimal expansion; no exact representable decimal result”
- how to use drawArc()
- How to add RGB values into setColor() in Java?
- Can you write virtual functions / methods in Java?
- Creating video player using Java
- Can I override and overload static methods in Java?
- How can i fix this equals on primitive type(int)