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.错误, ...
随机推荐
- 《Apache Spark源码剖析》
Spark Contributor,Databricks工程师连城,华为大数据平台开发部部长陈亮,网易杭州研究院副院长汪源,TalkingData首席数据科学家张夏天联袂力荐1.本书全面.系统地介绍了 ...
- 【canvas】基于坐标的碰撞检测 / 基本的动画 / 多物体动画
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- @repository注解
Spring的注解形式:@Repository.@Service.@Controller,它们分别对应存储层Bean,业务层Bean,和展示层Bean. @Repository.@Service.@C ...
- VS 2010不显示头文件源文件和所有以前分类的文件夹,*.h 和*.cpp都显示在同一个文件
打开VS后不显示头文件源文件和所有以前分类的文件夹,*.h 和*.cpp都显示在同一个文件 点击右图红色指示显示所有文件夹按钮,就能恢复.
- 工作总结之动画与VR
一.Unity5的动画新特性: 1.animator controller默认就包含Any State.Entry.Exit三个状态 2.animator可以给每个动画片段添加脚本,该脚本继承 Sta ...
- Torque2D MIT 学习笔记(27) ---- ImageFont的使用以及字体ImageAsset的工具生成
前言 ImageFont继承于SceneObject,是一个场景对象,支持例如旋转,缩放,移动加速度以及物理碰撞等一切Torque中场景对象的一切功能. ImageFont只支持ASCII编码表中的3 ...
- php写excel
$this->loadexcel(); $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties() ...
- xapian倒排索引的归并流程
Xapian的检索流程和大部分搜索系统都一样,就先从倒排表抽取候选文档,然后结合其他信息进行排序,取top文档作为搜索结果,具体流程如下: 图1 xapian搜索流程 具体流程 在terms中找到do ...
- GitHub上整理的一些工具,求补充
http://segmentfault.com/q/1010000002404545 技术站点 Hacker News:非常棒的针对编程的链接聚合网站 Programming reddit:同上 MS ...
- the partition number
有一个容量为n的背包,有1, 2, 3, ..., n这n种物品,每种物品可以无限使用,求装满的方案数. 法一: http://mathworld.wolfram.com/PartitionFunct ...