Created
February 7, 2014 02:10
-
-
Save ejknapp/8856327 to your computer and use it in GitHub Desktop.
Set demo from week 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package java112.labs1; | |
import java.io.*; | |
import java.util.*; | |
/** | |
* @author Eric Knapp | |
* class SetDemo | |
* TODO: comment | |
*/ | |
public class SetDemo { | |
public void run() { | |
Set<String> set = new TreeSet<String>(); | |
set.add("Three"); | |
set.add("One"); | |
set.add("Four"); | |
set.add("Two"); | |
set.add("Four"); | |
set.add("Four"); | |
set.add("Four"); | |
set.add("Four"); | |
set.add("Four"); | |
set.add("Four"); | |
System.out.println(set); | |
for (Iterator iterator = set.iterator(); iterator.hasNext(); ) { | |
String element = (String)iterator.next(); | |
System.out.println(element); | |
} | |
System.out.println(); | |
for (String element : set) { | |
System.out.println(element); | |
} | |
} | |
public static void main(String[] args) { | |
SetDemo demo = new SetDemo(); | |
demo.run(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment