摘要:
重载方法 public static void main(String[] args) { //重载方法 double max = max(15, 15); System.out.println(max);}//方法的重载方法名相同传递参数类型不同和返回值不同public static int ma 阅读全文
posted @ 2021-10-18 21:00
Java学痴
阅读(91)
评论(0)
推荐(0)
摘要:
break和continue break break 主要用于for循环和switch语句当中但是程序还会继续走下去(只是强制终止循环)for (int i=0;i<100;i++){ System.out.println(i); if (i==30){ break; }} continue con 阅读全文
posted @ 2021-10-18 19:17
Java学痴
阅读(125)
评论(0)
推荐(0)
摘要:
For循环 练习 1 求100以内的奇数 偶数之和 public static void main(String[] args) { //练习1求100以内的奇数 偶数之和 int oddsum=0;//奇数 int evensum=0;//偶数 for (int i=0 ;i<=100;i++){ 阅读全文
posted @ 2021-10-18 15:56
Java学痴
阅读(69)
评论(0)
推荐(0)
摘要:
while循环 1. public static void main(String[] args) { int num=1; int sum=0; while(num<100){ sum=sum+num; num++; System.out.println(num); } } 2.do while 阅读全文
posted @ 2021-10-18 11:38
Java学痴
阅读(97)
评论(0)
推荐(0)
摘要:
switch选择结构 public static void main(String[] args) { //case具有穿透性 如果不用break结束,它会把下面的语句一起执行了 char grade ='B'; switch (grade){ case 'A': System.out.printl 阅读全文
posted @ 2021-10-18 10:59
Java学痴
阅读(37)
评论(0)
推荐(0)
浙公网安备 33010602011771号