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);
}
}
}
对比
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);
}
}
}
总结