Easy way to create a list of something in Java

Опубликовано: 04 Июнь 2026
на канале: CSExplained
425
17

Creating a list in Java can be cumbersome compared to some modern languages... You have to create a new list (ArrayList or LinkedList or some other implementation), and then call the add method for every item you want to add to the list. Instead, you can use Java's List.of() static method to really quickly create a list of something. The only downside to this is that this list will be immutable, but the code is much more readable!

#shorts