-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectionAssignment.java
More file actions
34 lines (26 loc) · 965 Bytes
/
Copy pathCollectionAssignment.java
File metadata and controls
34 lines (26 loc) · 965 Bytes
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
package com.creatio.crm.language.basics;
import java.util.ArrayList;
import java.util.List;
public class CollectionAssignment {
public static void main(String[] args) {
/**
* ArrayList Assignment
Create an ArrayList of 5 course names
Print the total count
Print the first and last course
Remove one course and print the list again
Check if a specific course exists in the list using contains()
*/
List<String> courseName = new ArrayList<String>();
courseName.add("AI ML");
courseName.add("Automation Testing");
courseName.add("Cloud computing");
courseName.add("Embedded Sytem");
courseName.add("Web dev");
System.out.println(courseName.size());
System.out.printf("1st course: %s || last course: %s%n",courseName.get(0),courseName.get(courseName.size()-1));
System.out.println(courseName.remove(3));
System.out.println(courseName);
System.out.println(courseName.contains("Automation Testing"));
}
}