文件名称:while
- 所属分类:
- JSP源码/Java
- 资源属性:
- [Java] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 1kb
- 下载次数:
- 0次
- 提 供 者:
- 撒*
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
一个练习DO-WHILE,WHILE循环的程序,你根据它的要求写出对应的循环。- Below is a Java program that uses a while loop:
/**
* SquaringNumbers: Demonstration of while loop.
*/
public class SquaringNumbers {
public static void main(String[] args) {
int i = 1
while (i <= 10) {
System.out.println("The square of "+ i+ " is "+ i*i)
i++
}
}
}
Write a new version of the program above using a do-while loop and name its file SquaringNumbers1.java.
Write a new version of the program above using a for loop and name its file SquaringNumbers2.java.
/**
* SquaringNumbers: Demonstration of while loop.
*/
public class SquaringNumbers {
public static void main(String[] args) {
int i = 1
while (i <= 10) {
System.out.println("The square of "+ i+ " is "+ i*i)
i++
}
}
}
Write a new version of the program above using a do-while loop and name its file SquaringNumbers1.java.
Write a new version of the program above using a for loop and name its file SquaringNumbers2.java.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
SquaringNumbers1.class
SquaringNumbers1.java
SquaringNumbers2.class
SquaringNumbers2.java
SquaringNumbers1.java
SquaringNumbers2.class
SquaringNumbers2.java