📄 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);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -