Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Teste{
- private ArrayList<Teste> lista;
- String nome, idade;
- public Teste(String nome, String idade){
- lista = new ArrayList<Teste>();
- lista.add(new Teste("Felipe", "19"));
- lista.add(new Teste("Ana", "18"));
- lista.add(new Teste("Luis", "21"));
- lista.add(new Teste("Rogerio", "18"));
- lista.add(new Teste("Amanda", "25"));
- lista.add(new Teste("Augusto", "18"));
- lista.add(new Teste("Laura", "15"));
- }
- public String getIdade(){
- return idade;
- }
- public String buscaPessoaPorIdade(String idade){
- String t = "";
- for (Teste c: lista){
- if(c.getIdade().equals(idade)){
- t = t + c + "\n";
- }
- }
- return t;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement