【Java开源代码栏目提醒】:网学会员--在 Java开源代码编辑为广大网友搜集整理了:TestThis2.java绩等信息,祝愿广大网友取得需要的信息,参考学习。
public class TestThis2{
/*定义成员变量*/
String personName;//
int personAge;//年龄
String personSex;//性别
/*定义构造函数TestThis2()*/
public TestThis2(){
System.out.println("构造了一个新的对象!");
}
/*定义构造函数TestThis2(String name, int age, String sex)*/
public TestThis2(String name, int age, String sex){
this();
personName = name;
personAge = age;
personSex = sex;
}
public static void main(String args[]){
/*调用函数生成对象person */
TestThis2 person = new TestThis2("李玲",20,"女");
System.out.println(":"+ person.personName+",年龄:"+ person.personAge+",性别:"+ person.personSex);
}
}
上一篇:
TestThis1.java
下一篇:
兰州市2010年