Impressão alfabetica

1 resposta
E
case 4:

System.out.println("\tImprimir Listagem de Alunos");

for (;;){					

System.out.println(Digite um para impressão ou 0 para abortar);

int op1 = input.nextInt();	

if (op1==0)

break;

else

for (int k=0; k<novoAluno.length; k++){	

System.out.println(Matricula :”+novoAluno[k].getMatr());

System.out.println(Nome      :”+novoAluno[k].getNome());

System.out.println(Freq. :”+novoAluno[k].getFrequencia());
float [] notas = novoAluno[k].getNotas();
 for (int f=0 ;f&lt;notas.length; f++)
   System.out.println("Notas :"+ f+1 + notas [f]);

}

Necessito imprimir alfabeticamente a partir deste case
Alguem pode ajudar ?

1 Resposta

S
Arrays.sort &#40;novoAluno , new Comparator &#40;&#41;&#123;

           public int compare &#40;Object a , Object b&#41;&#123;
                   return &#40;&#40;Aluno&#41;a&#41;.getNome&#40;&#41;.compareTo&#40;&#40;Aluno&#41;b&#41;.getNome&#40;&#41;&#41;;
           &#125;

&#125;&#41;;

Coloque isto antes do for. Substitua Aluno pela classe de que o array novoAluno e` feito

Criado 24 de março de 2007
Ultima resposta 24 de mar. de 2007
Respostas 1
Participantes 2