我收到錯誤如下:學生出錯a =新生();
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
No enclosing instance of type New is accessible. Must qualify the allocation with an enclosing instance of type New (e.g. x.new A() where x is an instance of New). at n.New.main(New.java:7)
以下是我的代碼:
package n;
public class New
{
public static void main(String[] args)
{
Student a=new Student();
a.name="abc";
a.number=6;
a.marks=1;
System.out.println(a.name);
System.out.println(a.number);
System.out.println(a.marks);
}
class Student
{
String name;
int number;
int marks;
}
}
@SantoshReddy你真的*讀過*的錯誤信息? – Biffen
@ magic-sudo這兩個評論都是錯誤的,不需要做實際的事情,也不是編譯錯誤的錯誤 – SomeJavaGuy
這是什麼關於。其實我是一個初學者。你能告訴我這些改變嗎? –