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


Please Help Members By Posting Answers For Below Questions

what is abstract class in Java?

652


What does a method signature consist of?

508


Is java still necessary?

619


What is the difference between notify and notifyall method?

614


what is the difference between the methods sleep() and wait()? : Java thread

515






What is the different types of functions?

557


What are class members by default?

657


which is advanced deep technology in java launched by the sun microsystem??? The answer is very logical If u need correct answer mail me at priya_gupta@gmail.com

3190


What is the difference between the paint() and repaint() methods in java programming?

621


Is sizeof a keyword in java programming?

609


What is == in java?

563


What is the collections api?

569


Are arrays dynamic in java?

534


What is character in data type?

549


How to use arraylist in java netbeans?

508