File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
Data Structures in Java/Level 2/Linked List 1 Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .util .ArrayList ;
2
+
3
+ public class ArrayList {
4
+
5
+ public static void main (String [] args ) {
6
+
7
+ ArrayList <Integer > list1 = new ArrayList <>();
8
+
9
+ ArrayList <String > list2 = new ArrayList <>();
10
+
11
+ System .out .println (list1 .size ());
12
+ list1 .add (15 );
13
+
14
+ list1 .add (20 );
15
+ list1 .add (25 );
16
+ list1 .add (2 , 50 );
17
+ // System.out.println(list1.get(5));
18
+ // System.out.println(list1.size());
19
+ // System.out.println(list1.get(2));
20
+
21
+
22
+ for (int elem : list1 ){
23
+ System .out .print (elem + " " );
24
+ elem = 100 ;
25
+ }
26
+
27
+ System .out .println ();
28
+
29
+ for (int i = 0 ; i < list1 .size (); i ++){
30
+ System .out .print (list1 .get (i ) + " " );
31
+ }
32
+
33
+ // System.out.println();
34
+ // //list1.remove(1);
35
+ // list1.set(1, 100);
36
+ // for(int i = 0; i < list1.size(); i++){
37
+ // System.out.print(list1.get(i) + " ");
38
+ // }
39
+ //
40
+
41
+
42
+
43
+
44
+
45
+ }
46
+
47
+ }
You can’t perform that action at this time.
0 commit comments