一个赋值问题
three = one+ two; //为啥前面加上int数据类型就运行不了了呢?
three = one+ two; //为啥前面加上int数据类型就运行不了了呢?
2019-09-04
public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;这个地方已经有定义了three变量
three=one+two;所以在这里加int会出现报错
//
error: variable three is already defined in method main(String[]) int three=one+two;
//
System.out.println(" three = one + two==> "+three);
three=three+one;
System.out.println(" three += one ==> "+three);
three=three-one;
System.out.println(" three -= one ==> "+three);
three=three*one;
System.out.println(" three *= one ==> "+three);
three=three/one;
System.out.println(" three /= one ==> "+three);
three=three%one;
System.out.println(" three %= one ==> "+three);
}
}
举报