For some reason, this doesn't work
import java.util.*;
public class SetExample
{
public static void main(String[] args)
{
System.out.println(set().next().length());
}
public static Iterator set()
{
List<String> arr = new ArrayList<>(Arrays.asList("one", "fableeblee", "cacao", "pablo", "thelma", "hepatitis"));
Iterator<String> itr = arr.iterator();
System.out.println(itr.next().length());
return itr;
}
}
The one line in main gives me a "cannot find symbol error", but a method similar to it in the set() method works. Why is this? It works perfectly fine in main when I remove the .length(), but with it, it doesn't work.