/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
class Pessoa {
private int idade;
public Pessoa
(String nome,
int idade
) { this.nome = nome;
this.idade = idade;
}
return nome;
}
public void setNome
(String nome
) { this.nome = nome;
}
public int getIdade() {
return idade;
}
public void setIdade(int idade) {
this.idade = idade;
}
public String obterInformacoes
(){ return "Nome: " + nome + ", Idade: " + idade;
}
}
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
private static List<Pessoa> listaPessoas = new ArrayList<Pessoa>();
{
listaPessoas.add(new Pessoa("Ana", 10));
listaPessoas.add(new Pessoa("Filomena", 11));
listaPessoas.add(new Pessoa("Martim", 15));
listaPessoas.add(new Pessoa("Ana", 21));
listaPessoas.add(new Pessoa("Ana", 9));
listaPessoas.sort((p1,p2)-> {
int compNomes = p1.getNome().compareTo(p2.getNome());
return compNomes == 0 ? p1.getIdade()-p2.getIdade():compNomes;
});
listaPessoas.
forEach(x
->System.
out.
println(x.
obterInformacoes())); }
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBQZXNzb2EgewogICAgcHJpdmF0ZSBTdHJpbmcgbm9tZTsKICAgIHByaXZhdGUgaW50IGlkYWRlOwoKICAgIHB1YmxpYyBQZXNzb2EoU3RyaW5nIG5vbWUsIGludCBpZGFkZSkgewogICAgICAgIHRoaXMubm9tZSA9IG5vbWU7CiAgICAgICAgdGhpcy5pZGFkZSA9IGlkYWRlOwogICAgfQoKICAgIHB1YmxpYyBTdHJpbmcgZ2V0Tm9tZSgpIHsKICAgICAgICByZXR1cm4gbm9tZTsKICAgIH0KCiAgICBwdWJsaWMgdm9pZCBzZXROb21lKFN0cmluZyBub21lKSB7CiAgICAgICAgdGhpcy5ub21lID0gbm9tZTsKICAgIH0KCiAgIC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