Last active
August 29, 2015 14:05
-
-
Save tonysm/1861cb37bfdca2d1eecd to your computer and use it in GitHub Desktop.
JavaCollections - exemplo
This file contains hidden or 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
| import java.util.ArrayList; | |
| import java.util.Collection; | |
| public class Main { | |
| public static void main(String[] args) { | |
| Collection<String> nomes = new ArrayList<String>(); | |
| nomes.add("Primeiro nome digitado"); | |
| nomes.add("Segundo nome"); | |
| for (String nome:nomes) { | |
| System.out.println("Nome: " + nome); | |
| } | |
| System.out.println("Total de clients: " + nomes.size()); | |
| } | |
| } |
This file contains hidden or 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
| import java.util.List; | |
| import java.util.ArrayList; | |
| public class Main { | |
| public static void main(String[] args) { | |
| List<String> nomes = new ArrayList<String>(); | |
| List<String> emails = new ArrayList<String>(); | |
| nomes.add("Primeiro nome digitado"); | |
| emails.add("primeiro@example.com"); | |
| nomes.add("Segundo nome"); | |
| emails.add("segundo@example.com"); | |
| for (int i = 0; i < nomes.size(); i++) | |
| { | |
| System.out.println("Cliente: " + nomes.get(i)); | |
| System.out.println("Email: " + emails.get(i)); | |
| } | |
| System.out.println("Total de clients: " + nomes.size()); | |
| } | |
| } | |
| /** | |
| * output: | |
| * | |
| * Cliente: Primeiro nome digitado | |
| * Email: primeiro@example.com | |
| * Cliente: Segundo nome | |
| * Email: segundo@example.com | |
| * Total de clients: 2 | |
| * | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment