根据提示完善代码,大佬们救命
package ghs;
public class ghs {
class People {
String name;
boolean sex;
int age;
public People() {
System.out.println("调用了无参的构造方法"); }
public People(String name1,boolean sex1,int age1) { //有参构造方法
this.name = name1;
this.sex = sex1;
this.age = age1;
}
public void show() {
System.out.println("**************");
System.out.println("数据如下");
System.out.println("name="+name);
System.out.println("sex="+sex);
System.out.println("age="+age); }
}
public static class Test {
public static void main(String[] args) {
People p1=new People("张三","男",20);
p1.show();
People p2=new People("小丽","女",18);
p2.show();
//p2指向p1的存储空间
p2.show();
//p3指向p2的存储空间
p3.show();
}
}
你是想弄啥,p1和p2 信息互换还是啥。你定义的p1 p2也有错吧