Java 我的收藏有什么问题?

Java 我的收藏有什么问题?,java,queue,Java,Queue,我正在准备学校的期末考试,遇到了一些问题。 我为用户创建了不同的排序来对信息进行排序,但是我得到了不同的错误。 主要的一个是“类型集合中的方法排序(List,Comparator)不适用于参数(ApplicationList,ApplicationList.AgeComarator)”。 我不知道这意味着什么,也不知道如何修复它 代码如下: ApplicationList.Java import java.util.*; public class ApplicationList impleme

我正在准备学校的期末考试,遇到了一些问题。 我为用户创建了不同的排序来对信息进行排序,但是我得到了不同的错误。 主要的一个是“类型集合中的方法排序(List,Comparator)不适用于参数(ApplicationList,ApplicationList.AgeComarator)”。 我不知道这意味着什么,也不知道如何修复它

代码如下:

ApplicationList.Java

import java.util.*;

public class ApplicationList implements Comparable<ApplicationList>
{
    /**
     * variables within the queue class
     */
    private int maxSize;
    private String[] queArray;
    private int front;
    private int rear;
    private int nItems;

    /**
     * This is the constructor
     */
    public ApplicationList(int size) {
        maxSize = size;
        queArray = new String[maxSize];
        front = 0;
        rear = -1;
        nItems = 0;
    }

    /**
     * Adds to the bottom of the queue, and determines if the queue is full
     */
    public void enqueue(String j) {
        if (isFull()) {
            System.out.println("Queue is full");
        } else {
            if (rear == maxSize - 1)
                rear = front - 1;

            queArray[rear + 1]=j;
            rear++;
            nItems++;
        }
    }

    /**
     * dequeues items from the top of the queue
     */
    public String dequeue() {
        if (isEmpty()) {
            System.out.println("Queue is empty");
            return null;
        } else {
            String j = queArray[front];
            front++;
            if (front == maxSize)
                front = 0;

            nItems--;
            return j;
        }
    }

    /**
     * peeks at the front of the queue
     */
    public String peekFront() {
        return queArray[front];
    }

    /**
     * determines if the queue is empty
     */
    public boolean isEmpty() {
        return (nItems == 0);
    }

    /**
     * Determines if the queue is full
     */
    public boolean isFull() {
        return (nItems == maxSize);
    }

    /**
     * determines size of queue
     */
    public int size() {
        return nItems;
    }

    public void display()
    {
        for (int i = 0; i< nItems; i++)
            System.out.println(queArray[(front+i) % maxSize]);
        System.out.println(" ");
    }

    private String lastName;
    private String firstName;
    private int age;
    private String email;
    private String education;
    private String experience;

    public ApplicationList(String lastName, String firstName, int age, String email, String education, String experience)
    {
        this.lastName = lastName;
        this.firstName = firstName;
        this.age = age;
        this.email = email;
        this.education = education;
        this.experience = experience;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getEducation() {
        return education;
    }

    public void setEducation(String education) {
        this.education = education;
    }

    public String getExperience() {
        return experience;
    }

    public void setExperience(String experience) {
        this.experience = experience;
    }

    public String toString() {
        return "Applicant: Last Name: " + lastName + " ||| " +"First Name: " + firstName +" ||| " + " Email: " + email +" ||| " + " Age: " + age +" ||| " + 
                " Education: " + education +" ||| " + " Experience: " + experience;
    }

    static List<String> definedOrder = Arrays.asList("4+ years","2 years","Diploma","GED","NA");
    static Comparator<ApplicationList> EducationComparator= new Comparator<ApplicationList>() {
        public int compare(ApplicationList e1, ApplicationList e2) {
            return Integer.valueOf(definedOrder.indexOf(e1.getEducation())).compareTo(Integer.valueOf(e2.getEducation()));
        }
    };

    static class AgeComparator implements Comparator<ApplicationList> {
        public int compare(ApplicationList p1, ApplicationList p2) {
            int age1 = p1.getAge();
            int age2 = p2.getAge();

            if (age1 == age2)
                return 0;
            else if (age1 > age2)
                return 1;
            else
                return -1;
        }
    }

    public int compareTo(ApplicationList n) {
        return getLastName().compareTo(n.getLastName());
    }
}
import java.util.*;
公共类应用程序列表实现了可比较的
{
/**
*队列类中的变量
*/
私有int-maxSize;
私有字符串[]数组;
私人内部阵线;
私家车;
私人机构;
/**
*这是构造函数
*/
公共应用程序列表(整数大小){
最大尺寸=尺寸;
queArray=新字符串[maxSize];
正面=0;
后部=-1;
nItems=0;
}
/**
*添加到队列底部,并确定队列是否已满
*/
公共无效排队(字符串j){
如果(isFull()){
System.out.println(“队列已满”);
}否则{
如果(后==最大尺寸-1)
后=前-1;
queArray[rear+1]=j;
后++;
nItems++;
}
}
/**
*从队列顶部将项目出列
*/
公共字符串出列(){
if(isEmpty()){
System.out.println(“队列为空”);
返回null;
}否则{
字符串j=queArray[front];
前端++;
如果(前==maxSize)
正面=0;
硝酸盐--;
返回j;
}
}
/**
*偷看队伍的前面
*/
公共字符串{
返回数组[前];
}
/**
*确定队列是否为空
*/
公共布尔值为空(){
返回值(nItems==0);
}
/**
*确定队列是否已满
*/
公共布尔值isFull(){
返回值(nItems==maxSize);
}
/**
*确定队列的大小
*/
公共整数大小(){
返回nItems;
}
公共空间显示()
{
对于(int i=0;i年龄2)
返回1;
其他的
返回-1;
}
}
公共整数比较(应用程序列表n){
返回getLastName().compareTo(n.getLastName());
}
}
这是导致问题的驱动程序:

ApplicationDriver.Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class ApplicationDriver
{
    public static <T> void main(String[] args) throws IOException {
        ApplicationList Applicants = new ApplicationList(5);

        ApplicationList sSmith = new ApplicationList("Smith", "Steve", 34, "SSmith@work.email", "GED", "Did a review on other games, hoping to review yours as well." );
        ApplicationList jRosen = new ApplicationList("Rosen", "Jane", 23, "RosenWall@zmail.com", "4+ years", "Game reviewing was somthing I've always wanted to try." );
        ApplicationList hAbhul = new ApplicationList("Abhul", "Habib", 19, "SwimminIndian@LookIn.org", "NA", "I like playing games, and feel like I have good insight." );
        ApplicationList aJones = new ApplicationList("Jones", "Abigail",27, "Jonsin4Love@zmail.com", "2 years", "I went to school for journalism, and think that I can write a fair and honest review of your games." );
        ApplicationList gInsider = new ApplicationList("Insider", "Gaming",0, "Michael@G.Insider.com", "Diploma", "Hi there, I am Michael from Gaming Insider. I see you are an upcoming developer, and want to see what you can do." );

        Applicants.enqueue(sSmith.toString());
        Applicants.enqueue(jRosen.toString());
        Applicants.enqueue(hAbhul.toString());
        Applicants.enqueue(aJones.toString());
        Applicants.enqueue(gInsider.toString());

        boolean success;

        while(true) {
            System.out.print("Enter the first letter of ");
            System.out.print("display, sort, remove: ");
            int choice = getChar();
            switch(choice) {
                case 'd':
                    Applicants.display();
                    break;
                case 's':
                    System.out.print("Enter the first letter to sort by ");
                    System.out.print("name, age, education: ");
                    int select = getChar();
                case 'e':
                    Collections.sort(Applicants, ApplicationList.EducationComparator);
                    Applicants.display();
                    break;
                case 'a':
                    Collections.sort(Applicants, new ApplicationList.AgeComparator());
                    Applicants.display();
                    break;
                case 'n':
                    Collections.sort(Applicants);
                    Applicants.display();
                    break;
                case 'r':
                    Applicants.dequeue();
                    Applicants.display();
                    break;
                default:
                    System.out.println("Invalid Entry, retry\n");
            }
        }
    }

    public static String getString() throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String s = br.readLine();
        return s;
    }

    public static char getChar() throws IOException {
        String s = getString();
        return s.charAt(0);
    }

    public static int getInt() throws IOException {
        String s = getString();
        return Integer.parseInt(s);
    }
}
导入java.io.BufferedReader;
导入java.io.IOException;
导入java.io.InputStreamReader;
导入java.util.*;
公共类应用程序
{
公共静态void main(字符串[]args)引发IOException{
申请列表申请人=新申请列表(5);
ApplicationList sSmith=新的应用程序列表(“Smith”,“Steve”,34,”SSmith@work.email“,”GED“,”对其他游戏进行了评论,希望也能对你的游戏进行评论。”);
ApplicationList jRosen=新的ApplicationList(“Rosen”,“Jane”,23,”RosenWall@zmail.com“,“4年以上”,“游戏回顾是我一直想尝试的事情。”);
ApplicationList hAbhul=新的应用程序列表(“Abhul”,“Habib”,19,”SwimminIndian@LookIn.org我喜欢玩游戏,感觉自己有很好的洞察力;
ApplicationList aJones=新的应用程序列表(“Jones”,“Abigail”,27,”Jonsin4Love@zmail.com我上的是新闻学院,我认为