Skip to content

Instantly share code, notes, and snippets.

@filiperdt
Created June 17, 2021 16:58
Show Gist options
  • Save filiperdt/e3454c8b592988a9ab07d2047da351de to your computer and use it in GitHub Desktop.
Save filiperdt/e3454c8b592988a9ab07d2047da351de to your computer and use it in GitHub Desktop.
Formas de for each no Java
// for each 1
for(Mensagem mensagem : mensagens){
System.out.println(mensagem);
}
// for each 2 - Utilizando função
mensagens.forEach(mensagem -> {
System.out.println(mensagem);
});
// for each 3
mensagens.forEach(System.out::println);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment