慕仙7327719
2018-01-25 22:03
自己做了一遍运行错误,于是放到Eclipse上运行发现是int there = one + two; there前没引用类型,有两点不能理解的是减等于和除等于和模等于的规律。。求解
public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;
int there = one + two;
System.out.println("there = one + two ==>" + there);
there += one;
System.out.println("there += one ==>" + there);
there -= one;
System.out.println("there -= one ==>" + there);
there *= one;
System.out.println("there *= one ==>" + there);
there /= one;
System.out.println("there /= one ==>" + there);
there %= one;
System.out.println("there %= one ==>" + there);
int three = one + two ;
把前面那个int去掉,已经定义过three类型了,不用重新定义了
运行好像没问题啊,代码应该也没问题,除了three这个变量没用到,估计是打错了吧,不过第二个变量there也定义了,所以没问题。
three -= one; 等价于 three = three - one;
其他的也一样
Java入门第一季(IDEA工具)升级版
1165172 学习 · 17581 问题
相似问题