Java java.lang.ArithmeticException: / by zero问题解决

问题描述:

java.lang.ArithmeticException: / by zero

问题分析:

1、使用0作为除数导致了报错。

解决办法:

int n=0;
int m=2;
//除数不为0
if(n!=0){
    System.out.println(m/n);
}else{
    System.out.println("0不能做为除数");
}

猜你喜欢

转载自blog.csdn.net/qq_38974638/article/details/114977412
今日推荐