Last active
April 26, 2022 02:17
-
-
Save marcusvoltolim/c2bf8519b957302ba710165a850423e5 to your computer and use it in GitHub Desktop.
Java: Criando Listas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#### Criando uma lista vazia | |
List<Integer> lista = new ArrayList<>(); | |
//#### Criando uma lista inicializada antes do java9 | |
List<Integer> lista = new ArrayList<>(Arrays.asList(1, 2)); | |
//#### Criando uma lista inicializada a partir do java9 | |
List<Integer> lista = new ArrayList<>(List.of(1, 2)); | |
// Em ambos os exemplos com inicialização a lista resultante será: [1, 2] | |
//#### (Groovy) Criando uma lista vazia | |
List<Integer> lista = [] | |
//#### (Groovy) Criando uma lista inicializada | |
List<Integer> lista = [1, 2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment