forked from txs72/JavaTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestArrayListNew.java
More file actions
executable file
·57 lines (55 loc) · 1.75 KB
/
TestArrayListNew.java
File metadata and controls
executable file
·57 lines (55 loc) · 1.75 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
56
57
/* */ package ch19;
/* */
/* */ import java.util.ArrayList;
/* */
/* */ public class TestArrayListNew
/* */ {
/* */ public static void main(String[] args) {
/* 8 */ ArrayList<String> cityList = new ArrayList<>();
/* */
/* */
/* 11 */ cityList.add("London");
/* 12 */ cityList.add("New York");
/* 13 */ cityList.add("Paris");
/* 14 */ cityList.add("Toronto");
/* 15 */ cityList.add("Hong Kong");
/* 16 */ cityList.add("Singapore");
/* */
/* 18 */ System.out.println("List size? " + cityList.size());
/* 19 */ System.out.println("Is Toronto in the list? " + cityList
/* 20 */ .contains("Toronto"));
/* 21 */ System.out.println("The location of New York in the list? " + cityList
/* 22 */ .indexOf("New York"));
/* 23 */ System.out.println("Is the list empty? " + cityList
/* 24 */ .isEmpty());
/* */
/* */
/* 27 */ cityList.add(2, "Beijing");
/* */
/* */
/* 30 */ cityList.remove("Toronto");
/* */
/* */
/* 33 */ cityList.remove(1);
/* */
/* */
/* 36 */ for (int i = 0; i < cityList.size(); i++)
/* 37 */ System.out.print((String)cityList.get(i) + " ");
/* 38 */ System.out.println();
/* */
/* */
/* 41 */ ArrayList<Circle> list = new ArrayList<>();
/* */
/* */
/* 44 */ list.add(new Circle(2.0D));
/* 45 */ list.add(new Circle(3.0D));
/* */
/* */
/* 48 */ System.out.println("The area of the circle? " + ((Circle)list
/* 49 */ .get(0)).getArea());
/* */ }
/* */ }
/* Location: /Volumes/TXS.128G/hope useful/practice/2020.jar!/ch19/TestArrayListNew.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/