gpt4 book ai didi

java - Student a=new Student() 错误;

转载 作者:行者123 更新时间:2023-11-29 08:40:32 27 4
gpt4 key购买 nike

<分区>

出现如下错误:

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;

}

}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com