Skip to content

Commit ba3cb9b

Browse files
committed
usando generics em uma arraylist
1 parent 051019e commit ba3cb9b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package module3.arrayslist.generics.pt3;
2+
3+
import java.util.ArrayList;
4+
5+
public class TesteArrayListGenererics {
6+
7+
public static void main(String[] args) {
8+
9+
ArrayList<String> lista = new ArrayList<>();
10+
11+
String nome = new String("emanoel");
12+
lista.add(nome);
13+
14+
String sobrenome = new String("campos");
15+
lista.add(sobrenome);
16+
17+
System.out.println(lista.size());
18+
System.out.println(lista.get(1));
19+
20+
for (int i = 0; i < lista.size(); i++) {
21+
System.out.print(lista.get(i) + " ");
22+
}
23+
24+
for (String nomes : lista) {
25+
System.out.println(nomes);
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)