We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cce3904 commit 4cc24aeCopy full SHA for 4cc24ae
1 file changed
src/lab_04/lab_04.java
@@ -16,17 +16,21 @@ public class lab_04 {
16
17
public static void main(String[] args) {
18
19
- List<Integer> myArraylist = Arrays.asList(2, 4, 6, 8);
+ 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
+
26
Scanner input = new Scanner(System.in);
27
System.out.println("Please enter one number: ");
28
int userinput = input.nextInt();
- myArraylist.add(userinput);
- myArraylist.add(0,userinput);
-
29
30
switch (userinput) {
31
case 1:
32
System.out.println("Add number into Array list");
33
+ myArraylist.add(input.nextInt());
34
break;
35
case 2:
36
System.out.println("Please Print number");
0 commit comments