Skip to content

Instantly share code, notes, and snippets.

@thiagolinoz
Last active July 20, 2020 12:08
Show Gist options
  • Save thiagolinoz/62a02437cc8679e15912450b8599b3ef to your computer and use it in GitHub Desktop.
Save thiagolinoz/62a02437cc8679e15912450b8599b3ef to your computer and use it in GitHub Desktop.
example ArrayList e TreeSet
import java.util.List;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class HeroisCollection {
public static void main(String[] args) {
List<String> nomeHerois = new ArrayList<String>();
nomeHerois.add("Peter Parker");
nomeHerois.add("Bruce Wayne");
nomeHerois.add("Bruce Banner");
for (String nome : nomeHerois) {
System.out.println(nome);
}
System.out.println("------");
Set<String> herois = new HashSet<String>();
herois.add("Spider man");
herois.add("Batman");
herois.add("Hulk");
Iterator<String> heroi = herois.iterator();
while (heroi.hasNext()) {
System.out.println(heroi.next());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment