Here is what I\'m trying to use. The method .length doesn\'t work for anything I try, so I\'m not even sure where to begin.
import java.util.ArrayList;
public c
In the following code:
ArrayList lengthList = new ArrayList();
for (int nums: lengthList) {
System.out.println(nums.length());
}
You are creating an ArrayList
which is empty and trying to iterate over it.
I think you want to iterate over list
something like this:
for (String s: list) {
lengthList.add(s.length());
System.out.println(s.length());
}
and add length()
of each String
to lengthList
in each iteration.