public class add{public static void main(String[] args) {System.out.println(10 + 10);System.out.println("100" + 93);System.out.println(100 + 3 + "hello");System.out.println("hello" + 100 + 3);}
}
/*
20
10093
103hello
hello1003
**/
public class CharDetail{public static void main(String[] args) {char c1 = 'a';System.out.println(c1);//aSystem.out.println((int)c1);//97char c2 = 97;System.out.println(c2);//aSystem.out.println('a' + 10);//107char c5 = 'b' + 1;System.out.println((int)c5); //99System.out.println(c5); //c}
}
public class Convert{public static void main(String[] args) {int num = 'a';double d1 = 80;System.out.println(num);//97System.out.println(d1);//80.0//float a1 = 1.1f;float d2 = 2 + 1.1f;System.out.println(d2);//3.1}
}
public class Excecise{public static void main(String[] args) {int n1 = 100;float n2 = 1.1f;double n3 = 3.4;boolean n4 = true;String s1 = n1 + "";String s2 = n2 + "";String s3 = n3 + "";String s4 = n4 + "";System.out.println(s1 + " " + s2 + " " + s3 + " " + s4);//100 1.1 3.4 true//String->对应的基本数据类型String s5 = "123";int num1 = Integer.parseInt(s5);float num2 = Float.parseFloat(s5);System.out.println(num1);//123System.out.println(num2);//123.0boolean num3 = Boolean.parseBoolean("true");System.out.println(num3);//true//把字符串转成字符charSystem.out.println(s5.charAt(0));//得到s5字符串的第一个字符,1}
}
public class Homework{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 + " " + c2 + " " + c3 + " " + c4 + " " + c5 + " " + c6 + " " + c7);System.out.println("===========================");String book1 = "红楼梦";String book2 = "西游记";System.out.println(book1 + book2);//红楼梦西游记char c8 = '男';char c9 = '女';System.out.println(c8);//男System.out.println(c9);//女System.out.println(c8+c9);//52906float price1 = 1.1f;float price2 = 2.2f;System.out.println(price2+price1);//3.3000002System.out.println("==========================="); String name = "贾树行";int age = 29;double force = 80.5;char gender = '男';String like = "学习";System.out.println("姓名\t年龄\t成绩\t性别\t爱好\n" + name + '\t' + age + '\t' + force + '\t' + gender + '\t' +like);/*
姓名 年龄 成绩 性别 爱好
贾树行 29 80.5 男 学习*/}
}
上一篇:C语言指针函数
下一篇:C++021-C++二分查找