Back to Intellij Community

Description

java/java-impl/resources/intentionDescriptions/ReplaceWithArraysAsListIntention/description.html

2025.3-rc-2809 B
Original Source

Replaces a Collections.emptyList() or Collections.singletonList() call with a call to Arrays.asList().

When the project or module uses language level 9:

  • The intention replaces Collections.emptyList() or Collections.singletonList() with a call to java.util.List.of().
  • Replaces a Collections.emptySet() or Collections.singleton() call with java.util.Set.of().
  • Replaces a Collections.emptyMap() or Collections.singletonMap() call with java.util.Map.of().

When the project or module uses the Guava library and the language level is 9 or lower, the intention replaces a Collections.emptyList() or Collections.singletonList() call with com.google.common.collect.ImmutableList, com.google.common.collect.ImmutableSet, or com.google.common.collect.ImmutableMap respectively.