Can we iterate through collection using for loop?
Answer Posted / haneef
Yes, We can
Set set=new HashSet();
set.add("one");
set.add("two");
for(Iterator it=set.iterator();it.hasNext();)
{
System.out.println(it.next());
}
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
What is integer size in java?
Explain how to convert any java object into byte array.
Why do we need variables?
How to declare an arraylist in java?
What is a numeric digit?
Is arraylist dynamic in java?
What is runtime polymorphism or dynamic method dispatch?
What is object-oriented paradigm?
Should you use singleton pattern?
Explain the significance of listiterator.
Why main() method is public, static and void in java ?
What is cr keyboard?
What is the tradeoff between using an unordered array versus an ordered array?
Can a constructor call another constructor?
How do you add an element to an arraylist in java?