时间格式处理的小方法
来源:优易学  2011-1-18 13:02:04   【优易学:中国教育考试门户网】   资料下载   IT书店
  break用于强行推出循环,不执行循环中剩余的语句。continue用于停止执行当前的迭代,然后退回循环起始处,开始下一次迭代。看下面的代码:
  public class BreakAndContinue {
  public static void main(String[] args) {
  for(int i=0;i<100;i++){
  if(i==74) break;//Out of for loop
  if(i%9!=0)continue;//Next iteration
  System.out.println(i);
  }
  int i=0;
  //An \"infinite loop\":
  while(true){
  i++;
  int j=i*27;//40*27=1080,50*27=1350
  if(j==1269)break;//out of loop
  if(i%10!=0)continue;//Top of loop
  System.out.println(i);
  }
  }
  }
  结果:
  0
  9
  18
  27
  36
  45
  54
  63
  72
  10
  20
  30
  40

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训