ListSetMap
ListSetMap
*;
public class ListSetMap {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("Apple");
list.add("Banana");
list.add("Cherry");
list.add(1, "Mango");
System.out.println("\nList elements: " + list);
System.out.println("Element at index 2: " + list.get(2));
list.set(2, "Orange");
System.out.println("List after modification: " + list);
list.remove("Mango");
System.out.println("List after removing 'Mango': " + list);
System.out.println("Is 'Apple' in the list? " +
list.contains("Apple"));
System.out.println("Size of the list: " + list.size());
Set<String> set = new HashSet<>();
set.add("Dog");
set.add("Cat");
set.add("Bird");
set.add("Cat");
System.out.println("\nSet elements: " + set);
set.remove("Bird");
System.out.println("Set after removing 'Bird': " + set);
System.out.println("Is 'Cat' in the set? " + set.contains("Cat"));
System.out.println("Size of the set: " + set.size());