跟着老湿写的,为什么我的会编译报错,提示主函数中的三个new语句cannot be referenced from static context,我是抄的,他的都没有编译失败。好奇怪,到底哪里错了,谢谢
```java
package homework;
public class HomeWork01 {
public static void main(String[] args) {
Person[] persons = new Person[3];
persons[0] = new Person("maomao", 7, "dataengineer");
persons[1] = new Person("huic", 37, "java");
persons[2] = new Person("daoda", 35, "train");
for (int i = 0; i < persons.length; i++) {
System.out.println(persons[i]);
}
System.out.println("排序后:======================");
Person temp = null;
for (int i = 0; i < persons.length-1; i++) {
for (int j = 0; j < persons.length - i - 1; j++) {
if (persons[j].getJob().length() > persons[j + 1].getJob().length()) {
temp = persons[j];
persons[j] = persons[j + 1];
persons[j + 1] = temp;
}
}
}
for (int i = 0; i < persons.length; i++) {
System.out.println(persons[i].toString());
}
}
class Person {
private String name;
private int age;
private String job;
public Person(String name, int age, String job) {
this.name=name ;
this.age=age;
this.job=job;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
@Override
public String toString() {
return "Person{" +
"name='" + name + '\'' +
", age=" + age +
", job='" + job + '\'' +
'}';
}
}
}
```