This repository was archived by the owner on Aug 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathTopic 1.1.7.java
More file actions
55 lines (41 loc) · 1.58 KB
/
Topic 1.1.7.java
File metadata and controls
55 lines (41 loc) · 1.58 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Ссылка на проект с очередью: https://codeboard.io/projects/294054
// Работа с arrayList
import java.util.ArrayList;
public class HelloWorld{
public static void printArrayList(ArrayList<String> arrayList)
{
for(int i = 0; i < arrayList.size(); i++)
{
String value = arrayList.get(i);
System.out.print(value + " ");
}
System.out.println();
}
public static void printArraySize(ArrayList<String> arrayList)
{
System.out.println("Size of the arrayList is " + arrayList.size());
}
public static void main(String []args){
ArrayList<String> arrayList = new ArrayList<>();
printArrayList(arrayList);
arrayList.add("Anton");
printArrayList(arrayList);
arrayList.add("Mikhail");
printArrayList(arrayList);
arrayList.add("Anna");
printArrayList(arrayList);
arrayList.add("Mikhail");
printArrayList(arrayList);
arrayList.add(0,"Kate");
printArrayList(arrayList);
arrayList.add(2,"Daria");
printArrayList(arrayList);
arrayList.remove(0);
printArrayList(arrayList);
arrayList.remove("Mikhail");
printArrayList(arrayList);
arrayList.remove("Mikhail");
printArrayList(arrayList);
}
}
// Ссылка на работу с arrayList и linkedList: https://javarush.ru/groups/posts/dinamicheskie-massivy-java