System.out.print(o +" ");
may i know how the above code is represented in basic for loop?
there is no length attribute in set. instead, it has size()
expression must evaluate to the array to loop through. this could
be array variable or a method call that returns an array.
here 's' is not array. which is an set s = new Hashset();
how it works? correct me!
Originally posted by samura babu:
expression must evaluate to the array to loop through...
It does not need to be an array. The enhanced for statement can use either an array or any container that implements Iterable.
See JLS 14.14.2 The enhanced for statement.