慕娘1537045
2017-02-05 11:37
public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;
three=one+two;
/*↖(^ω^)↗加油哦 */
System.out.println("three = one + two ==> "+three);
three+=one;
System.out.println("three += one ==> "+three);
three-=one;
System.out.println("three -= one ==> "+three);
three*=one;
System.out.println("three *= one ==> "+three);
three/=one;
System.out.println("three /= one ==> "+three);
three%=one;
System.out.println("three %= one ==> "+three);
}
既然已经赋予了three=0了、为什么还写入、既然写入前边为什么不加入int
int three = 0既声明了three又初始化赋值为0,后让one和two加和赋值给three,再输入three的值显示在控制台,这时候打印出来才是 three = one + two ==> 30,否则打印出来是 three = one + two ==> 0,与要求就不符合了
因为最开始已经赋予了three 变量类型int,就无需再加入int。
Java入门第一季(IDEA工具)升级版
1165523 学习 · 17586 问题
相似问题
回答 2