public class ContinueTest {   public static void main( String args[] )
   {
      String output = "";
       int count = 1;
    while(  count <= 10 ) {  // loop 10 times         if ( count == 5 )  // if count is 5, 
            continue;       // skip remaining code in loop
        count++ ;
         output += count + " ";      } // end for      output += "\nUsed continue to skip printing 5";
      JOptionPane.showMessageDialog( null, output );      System.exit( 0 );  // terminate application   } // end main}

解决方案 »

  1.   

    你没有载入包啊import javax.swing.JOptionPane; 
      

  2.   

    在while循环里增加 System.out.println(output);
    显示的结果是 :

    2 3 
    2 3 4 
    2 3 4 5 
      

  3.   

    output += count + " "; 
    不知楼主这句话何意?
      

  4.   

     while(  count  <= 10 ) {  // loop 10 times           if ( count == 5 )  // if count is 5,  
                continue;       // skip remaining code in loop 
            count++ ;

             output += count + " ";        } // end for 看到没有?,当count==5的时候,每次都从开头去循环count==5。所以已经死循环了!
    这个简单问题,好改了吧?!
      

  5.   

    5的时候没有count++ ;就continue; 这个最后用for循环就非常简单了!
      

  6.   

    我把CONTINUE删了还是编译不动啊~ 
            嗷!~~~~~~~~~~~~~~~
      

  7.   

    我把CONTINUE删了还是编译不动啊~ 
            嗷!~~~~~~~~~~~~~~~
      

  8.   

    我把CONTINUE删了还是编译不动啊~ 
            嗷!~~~~~~~~~~~~~~~
      

  9.   

    如果非用while循环,代码如下:
    if ( count == 5 )  // if count is 5,  
                       // skip remaining code in loop 
             {count++;
             continue;}
             else count++ ;
             System.out.println(count);
             output += count + " "; 
      

  10.   

    我把CONTINUE删了还是编译不动啊~ 
            嗷!~~~~~~~~~~~~~~~
      

  11.   

    我把CONTINUE删了还是编译不动啊~ 
            嗷!~~~~~~~~~~~~~~~
      

  12.   

    我把CONTINUE删了还是编译不动啊~ 
            嗷!~~~~~~~~~~~~~~~
      

  13.   

    这个循环错了  
     int count = 1;
        while(  count  <= 10 ) {  // loop 10 times         if ( count == 5 )  // if count is 5, 
                continue;       // skip remaining code in loop
            count++ ;
             output += count + " ";      } // end for 
    因为你已经定义了 count=1 也就是说你的while循环相当于
    while(true)它会一直循环下去的,根本不会跳出来
      

  14.   

    为什么把CONTINUE删了也没用呢?
      

  15.   

    如果非用while循环,代码如下: 
    if ( count == 5 )  // if count is 5,   
                       // skip remaining code in loop  
             {count++; 
             continue;} 
             else count++ ; 
             System.out.println(count); 
             output += count + " "; 
      

  16.   

     for(int i=1;i<=10;i++){
       if(count==5)
             continue;      
             output += count + " ";
    }
      

  17.   

    import javax.swing.*;
    public class ContinueTest {    public static void main( String args[] ) 
       { 
          String output = ""; 
           int count = 0; 
        
        while(count<= 10 ) 
       
     {  // loop 10 times 
                    if ( count == 4 )  // if count is 5,  
     { 
     count =5;
     continue;}  
         else
     {
                      count++ ;
                      output += count + " ";
     }
      
                  } // end for       output += "\nUsed continue to skip printing 5";
      
          JOptionPane.showMessageDialog( null, output );       //System.exit( 0 );  // terminate application    } // end main }
    你是不是想跳过5这个数啊??
      

  18.   

    楼主循环到5的时候直接跳过但是没有累加就造成的死循环了。
    改成:
    if(count==5)
    {
      count++;
      continue;
    }
      

  19.   

    搂主有两个错误:1 包没有导入 2 while处当count =5时造成死循环 ,以下是修改过的正确代码:import javax.swing.JOptionPane;  public class ContinueTest {    public static void main( String args[] ) 
       { 
          String output = ""; 
          int count = 1; 
         
         while(count<=10) {   // loop 10 times           if ( count == 5 ){   // if count is 5,  
              count++;
                 continue; 
              }       // skip remaining code in loop 
                 
           count++ ; 
              output =  output+count+" ";       } // end loop      output += "\nUsed continue to skip printing 5"; 
          JOptionPane.showMessageDialog( null, output );       System.exit( 0 );   // terminate application    } // end main }
      

  20.   

    只要导入包后再if语句中加入count++一句即可
      

  21.   

        String output = ""; 
           int count = 1; 
        while(  count  <= 10 ) {  // loop 10 times          if ( count != 5 )  // if count is 5,  
             {
               
             output += count + " "; 
              count++ ; 
             } 
             else
             {
              count++;
              }
                }
           System.out.println(output);