Last active
July 20, 2020 12:08
-
-
Save thiagolinoz/62a02437cc8679e15912450b8599b3ef to your computer and use it in GitHub Desktop.
example ArrayList e TreeSet
This file contains hidden or 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
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