Given these classes, design a method in the \"People\" class which bubblesorts t
ID: 3656811 • Letter: G
Question
Given these classes, design a method in the "People" class which bubblesorts the "persons" in ascending order by "age". * Hints public class Person { private String name; private int age; : : } public class Numbers { private int [ ] num; private int capacity; private int size; : : } public class People { private Person [ ] persons; private int capacity; private int size; private Numbers x; : : } //***** public void bubblesort() { : : if (persons[i].getAge() //*int /**>**/ persons[i+?l].getAge //**Not sure what goes where the ? is.Explanation / Answer
public void bubblesort() { int size=persons.length(); int i,j; int temp; for(i=0;ipersons[j+1].getAge()) { temp=persons[j].getAge(); persons[j].setAge(persons[j+1].getAge()); persons[j+1].setAge(temp); } } } }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.