java学习之break,continue的用法

break

public static void main(String【】 args) {
        java.util.Scanner s = new java.util.Scanner(System.in);

        System.out.print(请输入第一个数字:);
        int num1 = s.nextInt();

        System.out.print(请输入运算符:);
        String operator = s.next();

        System.out.print(请输入第二个数字:);
        int num2 = s.nextInt();

        int result = 0;
        switch (operator){
            case + :
                result = num1 + num2;
                break;
            case - :
                result = num1 - num2;
                break;
            case * :
                result = num1 * num2;
                break;
            case / :
                result = num1 / num2;
                break;
            case % :
                result = num1 % num2;
                break;
            default:
                System.out.println(你的输入不合法!!!);
        }
        System.out.println(num1 + operator + num2 + = + result);

 

package com.zzz.base;

public class continueDome {
public static void main(String args[]){
int i=0;
while (i<100) {
i++;
    if(i%10==0) {
        System.out.println();
        break;
    }
        System.out.println(i);

    }
}
}



 

 java学习之break,continue的用法

 对比

continue 

package com.zzz.base;

public class continueDome {
public static void main(String args[]){
int i=0;
while (i<100) {
i++;
    if(i%10==0) {
        System.out.println();
        continue;
    }
        System.out.println(i);

    }
}
}





java学习之break,continue的用法

 

 总结

java学习之break,continue的用法

上一篇:立体定向活检仪行业调研报告 - 市场现状分析与发展前景预测


下一篇:JavaScript第一天练习