Syntax

Java Immutable List Syntax

In Java, immutable list: creates an unmodifiable list — List<Integer> nums = List.of(1, 2, 3);

Quick Answer

Syntax
List<Integer> nums = List.of(1, 2, 3);
JavaSyntax

Immutable List

Code example
List<Integer> nums = List.of(1, 2, 3);

Creates an unmodifiable list.

Learn More

How to immutable list in Java

  1. Open your Java file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Java Immutable List Syntax

Use List<Integer> nums = List.of(1, 2, 3);.

Related Syntax References

Frequently asked questions

What is the Java syntax for immutable list?

Use this pattern: List<Integer> nums = List.of(1, 2, 3);

Can I copy this Java code example?

Yes. Use Copy code and adapt the example to your program.

Is this Java syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify