import java.util.*;
class HelloWorld {
public static void main
(String[] args
) { ArrayList<Candidato> candidato = new ArrayList<>();
candidato.add(new Candidato("joao", 4));
candidato.add(new Candidato("jose", 2));
candidato.add(new Candidato("joaquim", 7));
int maiorVotos = 0;
Candidato maiorCandidato = null;
for (Candidato e: candidato) {
if(e.votos > maiorVotos) {
maiorVotos = e.votos;
maiorCandidato = e;
}
}
if (maiorCandidato != null) {
System.
out.
println("O presidente eleito é: " + maiorCandidato.
nome); }
}
}
class Candidato {
public int votos;
public Candidato
(String nome,
int votos
) { this.nome = nome;
this.votos = votos;
}
}
//https://pt.stackoverflow.com/q/209899/101
CmltcG9ydCBqYXZhLnV0aWwuKjsKCmNsYXNzIEhlbGxvV29ybGQgewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHsKCQlBcnJheUxpc3Q8Q2FuZGlkYXRvPiBjYW5kaWRhdG8gPSBuZXcgQXJyYXlMaXN0PD4oKTsKCQljYW5kaWRhdG8uYWRkKG5ldyBDYW5kaWRhdG8oImpvYW8iLCA0KSk7CgkJY2FuZGlkYXRvLmFkZChuZXcgQ2FuZGlkYXRvKCJqb3NlIiwgMikpOwoJCWNhbmRpZGF0by5hZGQobmV3IENhbmRpZGF0bygiam9hcXVpbSIsIDcpKTsKCSAgICBpbnQgbWFpb3JWb3RvcyA9IDA7CgkgICAgQ2FuZGlkYXRvIG1haW9yQ2FuZGlkYXRvID0gbnVsbDsKCSAgICBmb3IgKENhbmRpZGF0byBlOiBjYW5kaWRhdG8pIHsKCSAgICAgICAgaWYoZS52b3RvcyA+IG1haW9yVm90b3MpIHsKCSAgICAgICAgICAgIG1haW9yVm90b3MgPSBlLnZvdG9zOwoJICAgICAgICAgICAgbWFpb3JDYW5kaWRhdG8gPSBlOwoJICAgICAgICB9CgkgICAgfQoJICAgIGlmIChtYWlvckNhbmRpZGF0byAhPSBudWxsKSB7CgkgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiTyB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