2016.10.20 韬光养晦

阅读: 评论:0

2016.10.20 韬光养晦

2016.10.20 韬光养晦

今天复习java的流程结构,还是那句话,基础还是很重要.

1.switch

public class TestSwitch {public static void main(String[] args) {int a = 1;// String b = "今天是";switch (a) {case 1:System.out.println("星期一");break;case 2:System.out.println("星期二");break;case 3:System.out.println("星期三");break;case 4:System.out.println("星期四");break;case 5:System.out.println("星期五");break;case 6:System.out.println("星期六");break;case 7:System.out.println("星期天");break;default:System.out.println("there is nothing");}        }
}


2.do-wihile

do {System.out.println("至少让我执行一次");} while (i > 10);

3.for

阶乘

public class TestFor {public static void main(String[] args) {// 阶乘求值int jiecheng = 1;int num = 0;for (int i = 1; i < 10; i++) {jiecheng *= i;num += jiecheng;System.out.println(jiecheng);}System.out.println(num);}
}

蜜汁706

int bf, mf, lf;for (bf = 0; bf < 20; bf++) {for (mf = 0; mf < 100; mf++) {for (lf = 0; lf < 100; lf++) {if ((bf + mf + lf == 100) && (bf * 5 + mf + lf * 0.5 == 100)) {System.out.println(bf + " " + mf + " " + lf);}}}}

补充一下,可以用for(;;)来进行无限循环,因为这个根本不用判断,不像while True每次都要判断,也算一点点性能优化吧

break&continue&return

public class TestBreakContinueReturn {public static void main(String[] args) {for (int i = 1; i < 4; i++) {System.out.println("这是第" + i + "次外循环");for (int j = 1; j < 4; j++) {System.out.println("t" + "这是第" + j + "次内循环");break;}}for (int a = 1; a < 10; a++) {if (a == 6) {continue;}System.out.println(a);}for (int a = 1; a < 10; a++) {if (a == 8) {return;}System.out.println(a);}System.out.println("helloworld");}
}

break是跳出当前循环;continue是跳过当前操作继续循环;return是调处整个main方法

今天学到了activity的查看方法,很开心,很有成就感,不过今晚得把appium给入门了,干!!!

 

转载于:.html

本文发布于:2024-01-31 17:56:31,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170669499230323.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

下一篇:韬光养晦
标签:韬光养晦
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23