package bin_tree.heap;
import java.util.Queue;
import java.util.PriorityQueue;
public class PriorityQueueTest {
public static void main(String[] args) {
Queue<Student> queue = new PriorityQueue<>();
Student stu1=new Student("小明",18); // 报错行
}
class Student{
String name;
int age;
// Student构造方法
public Student(String name, int age) {
this.name = name;
this.age = age;
}
@Override
public String toString() {
return "Student{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}
}
}
Student stu1=new Student(“小明”,18); // 报错行
解决方法
1.将Student类从PriorityQueueTest 类中拿出来
2.将Student定义为静态类
一般就是将将Student类从PriorityQueueTest 类中拿出来
细心 细心 细心!!!