What does `List.of(1, 2, 3)` produce in Java 9+?

Java Professional Easy

Java Professional — Easy

What does `List.of(1, 2, 3)` produce in Java 9+?

Key points

  • `List.of()` creates an unmodifiable list
  • The elements passed are added to the list
  • This method is available in Java 9+
  • It returns a List interface implementation
  • The list is immutable

Ready to go further?

Related questions