Listfruits = new ArrayList<>(); fruits.add("apple"); fruits.add("banana"); fruits.add("orange"); System.out.println(fruits.size()); // Output: 3
ListIn this example, we use the `asList` method from the `Arrays` class to create a new `List` of `Integer` with five elements. Then we print the size of the list, which is 5. The `java.util.List` interface is part of the Java Collections Framework, which is a package library that provides a set of classes and interfaces for working with collections of objects.numbers = Arrays.asList(1, 2, 3, 4, 5); System.out.println(numbers.size()); // Output: 5