For some reason I find it very confusing and it took me a while to wrap my head around it (I think because the text is crap).
Anyways for some reason my first for loop is in a infinite loop and the second for loop is not even running. I used a System.out.println to diagnose what was going on. I am getting confused here tbh :S
Any help would be so appreciated (obviously
public static void sortEmployees(ArrayList<Employee>employees)
{
int count1;
int count2;
Employee element;
for(count1=1;count1<employees.size();count1++)
{
System.out.println("11111111");
element=employees.get(count1);
for(count2=count1;count2>0&&employees.get(count2-1).compareTo(element)>0;count2--)
{
System.out.println("22222222");
employees.add(count2,employees.get(count2-1));
}
employees.add(count2,element);
}
}

New Topic/Question
Reply



MultiQuote






|