0

Hello everyone I'm still studying java since I haven't used it for a long time. I found this exercise around and I didn't understand why the result is: one two three two three done

   public class Main{
    public static void main(String[] args){
      for(int i = 0; i < 3; i++) { 
        switch(i) { 
            case 0: break; 
            case 1: System.out.print("one "); 
            case 2: System.out.print("two "); 
            case 3: System.out.print("three "); 
     } 
   } 
    System.out.println("done");
    }
   }

 1° STEP i=0 -->nothing;
 2° STEP i=1 -->print one ;
 3° STEP i=2 -->print two ;

so my output should be: one two done; Why otput is:one two three two three done?

Elly
  • 345
  • 1
  • 8

0 Answers0