案例:身份登记,要求填写自己的姓名、年龄、性别、体重、婚姻状况(已婚为true,未婚为false)、联系方式等。
代码:
class StringTest{
public static void main(String[] args) {
String name = "张三";
int age = 24;
char gender = '男';
double weight = 130.5;
boolean isMarried = false;
String phoneNumber = "12345678987";
System.out.println("name = " + name + ",age = " + age + ",gender = " + gender +
"weight = " + weight + ",isMarried" + isMarried + ",phoneNumber" + phoneNumber);
}
}
结果: