数据类型
答:输出为:
n3 = 30
n5 = 8
public class Homework02 {
public static void main(String[] args) {
char c1 = '\n'; // 换行
char c2 = '\t'; // 制表位
char c3 = '\r'; // 回车
char c4 = '\\'; // 输出/
char c5 = '1';
char c6 = '2';
char c7 = '3';
System.out.println(c1);
System.out.println(c2);
System.out.println(c3);
System.out.println(c4);
System.out.println(c5);
System.out.println(c6);
System.out.println(c7);
}
}
运行结果:
public class Homework03 {
public static void main(String[] args) {
String book1 = "三体";
String book2 = "习近平谈治国理政";
System.out.println(book1 + book2); // 三体习近平谈治国理政
char c1 = '男';
char c2 = '女';
System.out.println(c1 + c2); // 得到码值
double price1 = 12.34;
double price2 = 11.01;
System.out.println(price1 + price2); // 即为小数相加
}
}
运行结果:
public class Homework04 {
public static void main(String[] args) {
String name = "Jack";
int age = 20;
double score = 90.5;
char gender = '男';
String hobby = "打篮球";
System.out.println("姓名\t年龄\t成绩\t性别\t爱好\n" + name + "\t" +
age + "\t" + score + "\t" + gender +
"\t" + hobby
);
}
}
运行结果
评论