Java 并不支持 goto 语句
4.1 true 和 false
4.2 if-else
4.3 迭代
4.3.1 do-while
4.3.2 for
4.3.3 逗号操作符
通过逗号操作符,可以在 for 语句内定义多个变量,但是它们必须具有相同的类型
4.4 Foreach 语法
4.5 return
4.6 break 和 continue
4.7 臭名昭著的 goto
嵌套循环与标签,貌似很少有用到
4.8 switch
吸血鬼数字
private static void bloodNum() {for (int i = 10; i < 100; i++) {for (int j = 10; j < 100; j++) {int temp = i * j;if (9999 > temp && temp > 999 && temp % 100 != 0) {System.out.println(i + " * " + j + " = " + temp);}}}}
斐波那契数列循环实现
private static void fibonacci(int size) {if (size == 1) {System.out.print(1);}if (size == 2) {System.out.print(1 + " " + 1);}if (size > 2) {System.out.print(1 + " " + 1);int x = 1;int y = 1;int temp;for (int i = 0; i < size; i++) {temp = x + y;x = y;y = temp;System.out.print(" " + temp);}}System.out.println();}
:::info
前几章都是比较基础的东西,平时有意无意用到的也很多~
位运算这块算是需要深入学习下的~
:::
