复制代码
- //:ListCharacters.java
- //Demonstrates"for"loopbylisting
- //alltheASCIIcharacters.
- publicclassListCharacters{
- publicstaticvoidmain(String[]args){
- for(charc=0;c<128;c++)
- if(c!=26)//ANSIClearscreen
- System.out.println(
- "value:"+(int)c+
- "character:"+c);
- }
- }///:~
复制代码
- for(inti=0,j=1;
- i<10&&j!=11;
- i++,j++)
- /*bodyofforloop*/;
复制代码
- //:CommaOperator.java
- publicclassCommaOperator{
- publicstaticvoidmain(String[]args){
- for(inti=1,j=i+10;i<5;
- i++,j=i*2){
- System.out.println("i="+i+"j="+j);
- }
- }
- }///:~
复制代码
- i=1j=11
- i=2j=4
- i=3j=6
- i=4j=8
欢迎光临 仓酷云 (http://ckuyun.com/) | Powered by Discuz! X3.2 |