Listnames = new ArrayList<>(); names.add("John"); names.add("Sarah"); names.add("Peter"); System.out.println(names.get(1)); // Output: Sarah
ListThis code creates a List of Integers using the Arrays.asList method and then reverses the order of the elements using the Collections.reverse method. The reversed list is then printed to the console. This example uses the Arrays class and the Collections class, both of which are part of the java.util package.numbers = Arrays.asList(1, 2, 3, 4); Collections.reverse(numbers); System.out.println(numbers); // Output: [4, 3, 2, 1]