qq_47072535
qq_47072535
采纳率0%
2020-04-14 20:37 阅读 252

person p1=new person class person出现错误

package asdw;

public class Arsd {

public static void main(String src[])
{
   Person p1=new Person(); 
        p1.name="陈华一";p1.sex="男"; p1.age=19; p1.height = 1.80f; p1.weight= 56;
        Person p2 =new Person();
        p2.name="陈一艺";p2.sex="女";p2.age=18; p2.height = 1.75f; p2.weight= 46;
        ((Arsd) p1).display();
        System.out.println("\n");
        ((Arsd) p2).display();

}
}
Class Person {
String name;
int age;
String sex;
float height;
float weight;
void display(){
System.out.println("大家好!,我的名字叫:"+name);
System.out.println("我的性别是:"+sex);
System.out.println("今年我:"+age+"岁");
System.out.println("身高:"+height+"米,体重:"+weight+"公斤");
}

}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐