java引用变量
publicclassPersonTest{publicstaticvoidmain(String[]args){Personperson=newPerson(50);S...
public class PersonTest
{
public static void main(String[] args)
{
Person person = new Person(50);
System.out.println(person.age);
}
class Person
{
int age;
public Person(int i)
{
age = i;
}
}
}
第五行报错 说无法从静态上下文中引用非静态 变量this
Person person = new Person() 箭头指new 求助啊这块真乱 展开
{
public static void main(String[] args)
{
Person person = new Person(50);
System.out.println(person.age);
}
class Person
{
int age;
public Person(int i)
{
age = i;
}
}
}
第五行报错 说无法从静态上下文中引用非静态 变量this
Person person = new Person() 箭头指new 求助啊这块真乱 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询