摘要: package com.lyc.struct;//break与continue的区别//break在任何循环语句的主体部分,均可用break控制循环的流程。// break用于强行退出循环,不执行循环中剩余的语句。// (break语句也在switch语句中使用)//continue语句用在循环语句 阅读全文
posted @ 2021-01-06 21:57 liuyunche 阅读(89) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class BreakDemo { public static void main(String[] args) { int i = 0; while (i<100){ i++; System.out.println(i); if (i== 阅读全文
posted @ 2021-01-06 21:51 liuyunche 阅读(68) 评论(0) 推荐(0) 编辑
摘要: break continuebreak在任何循环语句的主体部分,均可用break控制循环的流程。break用于强行退出循环,不执行循环中剩余的语句。(break语句也在switch语句中使用)continue 语句用在循环语句体中,用于终止某次循环过程,即跳过循环体中尚未执行的语句,接着进行下一次是 阅读全文
posted @ 2021-01-06 21:47 liuyunche 阅读(55) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class ForDemo05 { public static void main(String[] args) { int[] numbers = {10,20,30,40,50,60} ; //遍历数组的结果 //把numbers里的结 阅读全文
posted @ 2021-01-06 21:41 liuyunche 阅读(122) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class ForDemo04 { public static void main(String[] args) { //打印九九乘法表 for (int i = 1; i <= 9; i++) { for (int j = 1; j <= 阅读全文
posted @ 2021-01-06 21:31 liuyunche 阅读(75) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class ForDemo03 { public static void main(String[] args) { //用while或for循环输出1-1000之间能被5整除的数,并且每行输出3个 for (int i = 0; i <= 阅读全文
posted @ 2021-01-06 21:00 liuyunche 阅读(544) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class ForDemo02 { public static void main(String[] args) { //练习1:计算0到100之间的奇数和偶数的和 int odd = 0; int even = 0; //偶数// for 阅读全文
posted @ 2021-01-06 20:47 liuyunche 阅读(93) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class ForDemo01 { public static void main(String[] args) { int a = 1; while (a<=100){//条件判断 System.out.println(a); a+=2; 阅读全文
posted @ 2021-01-06 20:27 liuyunche 阅读(129) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class DoWhileDemo02 { public static void main(String[] args) { int a = 0; while (a<0){ System.out.println(a); a++; } Sys 阅读全文
posted @ 2021-01-06 20:11 liuyunche 阅读(87) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class DoWhileDemo01 { public static void main(String[] args) { //计算1+2+3+...+100 = ? int i = 0; int sum = 0; do { i++; s 阅读全文
posted @ 2021-01-06 20:05 liuyunche 阅读(80) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class WhileDemo02 { public static void main(String[] args) { //计算1+2+3+...+100 = ? int sum = 0; int i = 0; while (i<100) 阅读全文
posted @ 2021-01-06 19:53 liuyunche 阅读(83) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class WhileDemo01 { public static void main(String[] args) { //输出1~100 int i =0; while (i<100){ i++; System.out.println( 阅读全文
posted @ 2021-01-06 19:52 liuyunche 阅读(66) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class SwitchDemo02 { public static void main(String[] args) { String name = "史蒂夫"; //JDK7的新特性,表达式结果可以说字符串 //字符的本质还是数字 sw 阅读全文
posted @ 2021-01-06 19:41 liuyunche 阅读(68) 评论(0) 推荐(0) 编辑
摘要: package com.lyc.struct;public class SwitchDemo01 { public static void main(String[] args) { //case 穿透(如果不写break ,case将会把代码执行到底,所以匹配到选项后需要用break来终止) ch 阅读全文
posted @ 2021-01-06 19:39 liuyunche 阅读(156) 评论(0) 推荐(0) 编辑
摘要: package com.lyc;import java.util.Scanner;public class Demo05 { public static void main(String[] args) { //我们可以输入多个数字,并求其总和与平均数,每输入一份数字用回车确认,通过输入非数字来结束 阅读全文
posted @ 2021-01-06 17:13 liuyunche 阅读(44) 评论(0) 推荐(0) 编辑
摘要: package com.lyc;import java.util.Scanner;public class Demo04 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //从键 阅读全文
posted @ 2021-01-06 16:45 liuyunche 阅读(73) 评论(0) 推荐(0) 编辑
摘要: package com.lyc;import java.util.Scanner;public class Demo03 { public static void main(String[] args) { //创建一个扫描对象,用于接收键盘数据 Scanner scanner = new Scan 阅读全文
posted @ 2021-01-06 16:43 liuyunche 阅读(84) 评论(0) 推荐(0) 编辑