Skip to content

Commit 4cc24ae

Browse files
author
Tâm Lê
committed
new update for lab04
1 parent cce3904 commit 4cc24ae

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/lab_04/lab_04.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,21 @@ public class lab_04 {
1616

1717
public static void main(String[] args) {
1818

19-
List<Integer> myArraylist = Arrays.asList(2, 4, 6, 8);
19+
List<Integer> myArraylist = new ArrayList<Integer>();
20+
myArraylist.add(1);
21+
myArraylist.add(2);
22+
myArraylist.add(3);
23+
myArraylist.add(4);
24+
System.out.println("My arraylist is: "+ myArraylist);
25+
2026
Scanner input = new Scanner(System.in);
2127
System.out.println("Please enter one number: ");
2228
int userinput = input.nextInt();
23-
myArraylist.add(userinput);
24-
myArraylist.add(0,userinput);
25-
2629

2730
switch (userinput) {
2831
case 1:
2932
System.out.println("Add number into Array list");
33+
myArraylist.add(input.nextInt());
3034
break;
3135
case 2:
3236
System.out.println("Please Print number");

0 commit comments

Comments
 (0)