What variable is the ArrayList that you are trying to get data from? Using []s is for arrays.Quote:
read a certain line of an ArrayList...
An ArrayList is a class which means you need to use its methods to get to its contents.
Printable View
What variable is the ArrayList that you are trying to get data from? Using []s is for arrays.Quote:
read a certain line of an ArrayList...
An ArrayList is a class which means you need to use its methods to get to its contents.
I'm converting ints to strings to add to an array list and then trying to read the line of the arraylist to convert it back to an int. What method should I use to get the int/string?
For int to String see the String class's value of method or the Integer class's toString method.
I'm already using toString, the problem is reading the string from the ArrayList. I'm thinking the toArray() method might be the answer, but it seems like it wastes resources.
Please post the code you are having trouble with and describe what the problem is.Quote:
the problem is reading the string from the ArrayList.
Nevermind, I saw a method in the suggested endings list in Eclipse called ".get(index)". Apparantly Arraylist.get(index) was exactly what I needed! Thanks for all the help you guys!
Reading the API doc for the classes you are using can make writing code easier.
See post #26.