How can I add a quick sort to this program and not return the [Ljava.lang.Object;@5dfcfece with the results?
The program should provide the contents of the queue and then sort the queue using the quick sort in two ways:
Descending order by last name. Descending order by age.
import java.util.LinkedList;
import java.util.Scanner;
public class personQueue
{
private static Scanner scnr;
public static void main(String[] args)
{
LinkedListtheQ = new LinkedList < > ();
scnr = new Scanner(System.in);
int i;
for (i = 0; i < 5; i++) {
System.out.println("Enter the fist name of the person in queue position " + (i + 1) + ":\n");
String first = scnr.next();
System.out.println("Enter the last name of the person in queue position " + (i + 1) + ":\n");
String last = scnr.next();
System.out.println("Enter the age of the person in queue position " + (i + 1) + ":\n");
int age = scnr.nextInt();
theQ.add(new Person(first, last, age));
}
System.out.print(theQ.toArray());
for (int j = 0; j < theQ.toArray().length; j++)
{
System.out.println(theQ.toArray()[j].toString());
}
}
}
public class Person implements Comparable < Person > {
String first;
String last;
int age;
public Person(String firstName, String lastName, int age) {
this.first = firstName;
this.last = lastName;
this.age = age;
}
public String toString() {;
return "\n " + this.first + " " + this.last + " " + this.age + "\n ";
}
public int compareTo(Person arg0) {
return 0;
}