Exception in thread "main" 什么错误啊?
java.lang.Error: Unresolved compilation problems:
P1 cannot be resolved
P2 cannot be resolved
P3 cannot be resolved
at hello.main(hello.java:32)
Exception in thread "main"
代码如下
class Person
{
private String name="unknown";
private int age = -1;
public Person()
{
System.out.println("constructor1 is calling");
}
public Person(String n)
{
name = n;
System.out.println("constructor2 is calling");
System.out.println("name is "+name);
}
public Person(String n,int a)
{
name = n;
age = a;
System.out.println("constructor3 is calling");
System.out.println("name and age is "+name+";"+age);
}
public void shout()
{
System.out.println("listen to me!!");
}
}
class hello
{
public static void main(String[] args)
{
Person p1=new Person();
P1.shout();
Person p2=new Person("Jack");
P2.shout();
Person p3=new Person("Tom",18);
P3.shout();
}
}