Answer the question
In order to leave comments, you need to log in
Why doesn't the length method work?
Hello, writes cannot resolve the method length, I don’t understand why, if I need to take the length of the array with it?
Answer the question
In order to leave comments, you need to log in
In order for the ArrayList to know what objects are stored in it, you need to specify their class explicitly:
Then list.get(i) will return a String and the desired code will work.
Writing is
equivalent to writing
In this case, list.get(i) returns not a String, but an Object, which simply does not have a length() method
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question