How to use goto statement correctly

前端 未结 8 1759
自闭症患者
自闭症患者 2020-12-02 14:50

I am taking my high school AP Computer Science class.

I decided to throw a goto statement into a one of our labs just to play around, but I got this er

8条回答
  •  春和景丽
    2020-12-02 15:06

    If you look up continue and break they accept a "Label". Experiment with that. Goto itself won't work.

    public class BreakContinueWithLabel {
    
        public static void main(String args[]) {
    
            int[] numbers= new int[]{100,18,21,30};
    
            //Outer loop checks if number is multiple of 2
            OUTER:  //outer label
            for(int i = 0; i

    Read more

提交回复
热议问题