Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3. public class Teste{
  4. private ArrayList<Teste> lista;
  5. String nome, idade;
  6. public Teste(String nome, String idade){
  7. lista = new ArrayList<Teste>();
  8. lista.add(new Teste("Felipe", "19"));
  9. lista.add(new Teste("Ana", "18"));
  10. lista.add(new Teste("Luis", "21"));
  11. lista.add(new Teste("Rogerio", "18"));
  12. lista.add(new Teste("Amanda", "25"));
  13. lista.add(new Teste("Augusto", "18"));
  14. lista.add(new Teste("Laura", "15"));
  15. }
  16. public String getIdade(){
  17. return idade;
  18. }
  19. public String buscaPessoaPorIdade(String idade){
  20. String t = "";
  21. for (Teste c: lista){
  22. if(c.getIdade().equals(idade)){
  23. t = t + c + "\n";
  24. }
  25. }
  26. return t;
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement