Listfruits = new ArrayList<>(); fruits.add("Apple"); fruits.add("Banana"); fruits.add("Orange"); String fruit = fruits.get(1); // returns "Banana"
String[] cars = {"BMW", "Mercedes", "Audi"}; String car = cars.get(2); // returns "Audi"
MapThe `get()` method is part of the Java Collections Framework, which is included in the `java.util` package.scores = new HashMap<>(); scores.put("John", 80); scores.put("Mary", 90); int score = scores.get("Mary"); // returns 90