- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPegadinhasArrayList.java
More file actions
Latest commit
32 lines (22 loc) · 730 Bytes
/
Copy pathPegadinhasArrayList.java
File metadata and controls
32 lines (22 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
importjava.util.ArrayList;
publicclassPegadinhasArrayList {
publicstaticvoidmain(String[] args) {
ArrayList<Integer> num = newArrayList<>();
num.add(1);
num.add(2);
num.add(3);
IntegeriObj = 1;
//Quando utlizamos o Wrapper do Integer ele remove o objeto com o valor
num.remove(iObj);
System.out.println(num);
ArrayList<Integer> num2 = newArrayList<>();
//Index
num2.add(1); //0
num2.add(2); //1
num2.add(3); //2
intiPri = 2;
//Quando utlizamos o Primitivo do int ele remove conforme o index.
num2.remove(iPri);
System.out.println(num2);
}
}