For and While loop choice.
/*
Difference between 'for' and 'while'.
We can transform everything between 'for' and 'while'.
if the incremnet is just use for increase,we recommended 'for';
but if we want to preserved the increment and use it after the loop,'while' is recommented.
*/
import kju.print.Print;
class ForWhile
{
public static void main(String[] args)
{
/*
'i' is created after 'for',so it was release after the close brace.
*/
for(int i = 0; i < 3; i++) {
Print.println("i = " + i);
}
/*
i = 0
i = 1
i = 2
*/
//Print.println("after the loop, i = " + i); //compile error,i does not exist. Print.println("-----------");
/*
'j' is created before 'while',so it was preserved after the close brace.
*/
int j = 0;
while(j < 3){
Print.println("j = " + j);
j++;
}
/*
j = 0
j = 1
j = 2
*/
Print.println("after the loop, j = " + j);
//after the loop, j = 3
}
}
For and While loop choice.的更多相关文章
- Zabbix agent 在windows上安装部署
Zabbix agent 在windows上安装部署 1.下载与解压 地址: http://www.zabbix.com/downloads/2.4.4/zabbix_agents_2.4.4.win ...
- 识别简单的答题卡(Bubble sheet multiple choice scanner and test grader using OMR, Python and OpenCV——jsxyhelu重新整编)
该博客转自www.pyimagesearch.com,进行了相关修改补充. Over the past few months I've gotten quite the number of reque ...
- Atitit 解决Unhandled event loop exception错误的办法
Atitit 解决Unhandled event loop exception错误的办法 查看workspace/.metadata/.log org.eclipse.swt.SWTError: No ...
- Looper.prepare()和Looper.loop()
什么时候需要 Looper Looper用于封装了android线程中的消息循环,默认情况下一个线程是不存在消息循环(message loop)的,需要调用Looper.prepare()来给线程创建 ...
- PostgreSQL-PL/pgSQL-cursor,loop
将spam_keyword表word字段的字符全部拆分,只是利用过程语言完成循环的操作而已. create or replace function proc1() returns setof text ...
- archlinux 加载loop模块,且设定loop设备个数
如果loop模块没有编译进内核就要先加载loop模块 modprobe loop 然后更改/etc/modprobe.d/modprobe.conf(有些文章写是在/etc/modprobe.conf ...
- 工作邮件loop的用法
examples come from native speaker Put john in the loop about this. He will have good advice. Why hav ...
- bat脚本参数 if goto choice for使用的学习笔记。
写过几次bat脚本,但一直没有总结,最近找到一个网页介绍bat,总结得很好,转自 http://www.jb51.net/article/49627.htm: 本文只总结我不会的,全面的看原网页就可以 ...
- VMWare虚拟机实例拷贝到另一台服务器后出现Error in the RPC receive loop: RpcIn: Unable to send.错误的解决
把一个VMWare虚拟机实例拷贝到另一台服务器后,在事件查看器中的应用程序日志中不断出现Error in the RPC receive loop: RpcIn: Unable to send.错误, ...
随机推荐
- Optimal Milking
poj2112:http://poj.org/problem?id=2112 题意:K台挤奶机器,C头牛,K不超过30,C不超过200,每台挤奶机器最多可以为M台牛工作,给出这些牛和机器之间,牛和牛之 ...
- [jobdu]调整数组顺序使奇数位于偶数前面
这道题的代码没啥好说的,用了O(n)的空间就是水题了.但可以讲一下思考过程.一开始是想O(1)的空间的,然后想从左往右双指针扫,然后根据出现顺序交换遇到的偶数和奇数.但遇到一个问题:1, 2, 3, ...
- mysql中TimeStamp和Date的转换
mysql 查询时间戳(TIMESTAMP)转成常用可读时间格式 from_unixtime()是MySQL里的时间函数 date为需要处理的参数(该参数是Unix 时间戳),可以是字段名,也可以直接 ...
- LeetCode 面试:Add Two Numbers
1 题目 You are given two linked lists representing two non-negative numbers. The digits are stored in ...
- git cherry-pick 从其他分支检出指定的commit到当前分支
http://think-like-a-git.net/sections/rebase-from-the-ground-up/cherry-picking-explained.html Git's o ...
- bzoj3689
这题做法很多可以通过类似noi超级钢琴那道题目的做法用可持久化+trie来做还可以直接在trie树上维护size域然后类似查找k大的做法做总之还是比较水的 type node=record kth,n ...
- del重复数
楼主 发表于: 2010-06-21 11:46:31 本帖最后由 luckycynthia 于 2010-06-21 11:47:46 编辑 在抓取数据后对数据进行操作的途中,有时候会碰到重复数据, ...
- mapreduce 倒排索引的建立
大道至简 http://blog.csdn.net/hguisu/article/details/7969757 1.map的输入 key: 文档 id value: 文档内容 输出: key ...
- SWMM代码移植到64位平台
在32位平台上运行SWMM模型,当节点数量到达60万以上的时候,模型运行占用内存接近1.85G的时候就会因为内存不够而无法计算.这种情况还是单独运行SWMM.exe的时候出现,如果采用SWMM.DLL ...
- 让x86的android模拟器能模拟arm架构系统
网上介绍共计三种模拟器比较常用,分别是bluestacks.andy和Genymotion,前者支持ARM架构,中者支持远程控制,后者启动速度快,各有优缺点. 如果要用genymotion模拟arm的 ...