Hi..
Following is the code i worked on to sort the lastnames.I need to know how to append firstname along with middlename to respective lastname. What I need to do to get the specified output? Thanks.
Following is the code i worked on to sort the lastnames.I need to know how to append firstname along with middlename to respective lastname. What I need to do to get the specified output? Thanks.
Code:
while ((s= in.readLine()) != null){
String[] names = s.split(" ");
lastname[e] = names[names.length-1];
System.out.println(lastname[e]);
e++;
}
for (int i=0;i<e-1;i++){
for (int j=0;j<e-1;j++){
if(lastname[i].compareTo(lastname[j])<0)
{
String temp= lastname[j];
lastname[j]= lastname[i];
lastname[i]=temp;
}
}
}
for(int i=0; i<e-1; i++)
{
System.out.println(lastname[i]);
}
Comment