L
L
Lord Drous2017-05-15 12:51:07
Java
Lord Drous, 2017-05-15 12:51:07

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?25caa48c12944e9389805b26ec5202bc.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Labunsky, 2017-05-15
@LorDDrouS

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 question

Ask a Question

731 491 924 answers to any question