课后作业编码
public class Homework02{
public static void main(String[] args) {
char c1 = '\n';
char c2 = '\t';
char c3 = '\\';
char c4 = '\r';
char c5 = '1';
char c6 = '2';
char c7 = '3';
System.out.println("开始");
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 bookName1 = "唐诗300";
String bookName2 = "小王子";
char sex1 = '男';
char sex2 = '女';
double price1 = 123.12;
double price2 = 34.2;
System.out.println(bookName1 + bookName2);
System.out.println(sex1 + sex2);
System.out.println(price1 + price2);
}
}
public class Homework04{
public static void main(String[] args) {
String name = "金先生";
int age = 12;
double grade = 99;
char sex = '男';
String hobby = "打羽毛球";
System.out.println("姓名\t年龄\t成绩\t性别\t爱好\n" +
name + "\t" + age + "\t" + grade + "\t" + sex + "\t" + hobby);
}
}