You can use an enhanced for loop:
Set<String> set = new HashSet<String>();
//populate set
for (String s : set) {
System.out.println(s);
}
Or with Java 8:
set.forEach(System.out::println);
More Related Contents:
- How to calculate the intersection of two sets? [duplicate]
- HashSet contains duplicate entries
- Java HashSet with a custom equality criteria? [duplicate]
- My first for loop
- I don't know what's wrong with the do-while loop
- Printing Binary values using nested loops [closed]
- JAVA Looping a formula
- Optimizing a while loop in Java
- Sorting ArrayList based on number of duplicates? [closed]
- In Java, what are the advantages of streams over loops? [closed]
- A for-loop to iterate over an enum in Java
- Getting the difference between two sets
- What is the best way get the symmetric difference between two sets in java?
- Enhanced ‘for’ loop causes an ArrayIndexOutOfBoundsException
- Display numbers from 1 to 100 without loops or conditions [closed]
- Is there any way to do n-level nested loops in Java?
- HashSet does not seem to realize that two objects are the same.
- Should I avoid using Java Label Statements?
- Removing items from a collection in java while iterating over it
- Increment variable names? [duplicate]
- Any implementation of Ordered Set in Java?
- Changing HashMap keys during iteration
- Java: how much time does an empty loop use?
- Efficiently finding the intersection of a variable number of sets of strings
- Classical set operations for java.util.Collection
- using labels in java without “loops”
- Is it bad practice to use break to exit a loop in Java? [closed]
- How to use goto statement correctly
- Java Delay/Wait
- Java: For-Each loop and references [duplicate]