有人可以帮助我吗?我是java编程新手,我是否陷入了一个bug很长一段时间
这是错误消息:java.lang.ExceptionInInitializerError
引起原因:java.lang.RuntimeException:无法编译的源代码 - 需要标识符
at pkg18148600a_assignment1.Main.<clinit>(Main.java:12)
线程“main”Java 结果中出现异常:1
这是我的代码
public static void main(String[] args) {
Member member[] = new Member[6];
int sequence[] = {0,1,2,3,4,5};
int temp;
for (int i = 0; i < args.length; i++){
if (i % 2 == 0){
member[i] = new Member(args[i], Integer.valueOf(args[i+1]));
}
}
int k = 0;
boolean swap;
do{
swap = false;
if (member[k % 7].compareTo(member[(k+1) % 7]) > 0){
temp = sequence[k % 7];
sequence[k % 7] = sequence[(k+1) % 7];
sequence[(k+1) % 7] = temp;
swap = true;
}
k++;
} while(swap);
for (int i = 0; i < args.length; i++)
System.out.printf("%s, %d\n", member[i].getName(), member[i].getAge());
}
public static class Member implements Comparable<Member> {
private String name;
private int age;
public Member(String name, int age){
this.name = name;
this.age = age;
}
public Member(){
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
@Override
public int compareTo(Member a) {
if (age == a.age){
return 0;
}else if (age > a.age){
return 1;
}else return -1;
}
}
有只小跳蛙
相关分类