摘要: 循环结构 for循环 一种特殊的方式 int[] numbers = {10,20,30,4,50}; for (int x:numbers) { System.out.println(x); } 打印三角形 5行 for (int i = 0; i < 5; i++) { for (int j = 阅读全文
posted @ 2023-09-25 20:30 记录从头开始学java 阅读(47) 评论(0) 推荐(0)
摘要: Scanner 这个程序虽然有两个接收但是指输出了一次hello world Scanner sc = new Scanner(System.in); System.out.println("请输入hello world查看这两种方式的区别:"); System.out.println("使用nex 阅读全文
posted @ 2023-09-25 20:22 记录从头开始学java 阅读(27) 评论(0) 推荐(0)
摘要: 运算符 int c = 5; boolean a = (c<4)&&(++c<4); //此时 因为 c<4肯定是false所有在与(&&)运算中结果肯定为false 后面的就不执行了 System.out.println(c); // 这叫短路运算 c还是等于5 System.out.printl 阅读全文
posted @ 2023-09-25 20:01 记录从头开始学java 阅读(15) 评论(0) 推荐(0)
摘要: 数据类型转换 由于java是强类型的语言,所以有些运算时要进行类型转换 运算时,不同类型的数据先转换为同一类型,然后再进行运算 容量大小 byte,short,char -> int -> long -> float -> double float 没有 lang 长但是在后面是因为小数的优先级要高 阅读全文
posted @ 2023-09-25 18:52 记录从头开始学java 阅读(25) 评论(0) 推荐(0)