There are several syntax errors in your code. Here is the corrected version:

public class Test {
    public static void main(String[] args) {
        int a = 0;
        while(a <= 20) {
            switch (a) {
                case 0:
                case 1:
                    a = a + 2;
                    break;
                case 2:
                case 3:
                    a = a + 3;
                    break;
                default:
                    a = a + 5;
            }
            System.out.println('a=' + a);
        }
    }
}

Here are the changes I made:

  • Added closing parentheses for the class declaration and the main method declaration.
  • Replaced the exclamation mark (!) with an array brackets ([]) in the main method declaration.
  • Added opening and closing curly braces ({}) for the while loop and the switch statement.
  • Added break statements after each case in the switch statement.
  • Replaced 'System,out.print' with 'System.out.println' to print the output on a new line.

原文地址: https://www.cveoy.top/t/topic/o4pO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录