摘要: 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) 编辑
摘要: scanner对象 next(): 1、一定要读取到有效字符后才可以结束输入。 2、对输入有效字符之前遇到的空白,next()方法会自动将其去掉。 3、只有输入有效字符后才将其后面输入的空白作为分隔符或者结束符。 4、next()不能得到带有空格的字符串。 nextLine(): 1、以Enter为 阅读全文
posted @ 2021-01-05 21:36 liuyunche 阅读(79) 评论(0) 推荐(0) 编辑