灰会飞飞
2021-03-09 17:40
public class HelloWorld{
public static void main(String[] args) {
int one = 10 ;
int two = 20 ;
int three = 0 ;
three=one+two=30;
System.out.println(three);
three+=one=40;
three-=one=30;
three*=one=300;
three/=one=30;
three%=one=0;
System.out.println(three+=one);
System.out.println(three-=one);
System.out.println(three/=one);
System.out.println(three%=one);
一个句子之中只能有一个=号
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); three+=one; System.out.println(three); three-=one; System.out.println(three); three*=one; System.out.println(three); three/=one; System.out.println(three); three%=one; System.out.println(three); } }
左面等于号算数运算符,右面是赋值运算符,题目的意思是让你得到这些结果,不是让你去赋值,three=one+two;
three此时的值已经是30了,达到题目要求,同理下面也是这样,因此你可以在每一行后面都进行一次输出,System.out.println(three);
Java入门第一季(IDEA工具)升级版
1165553 学习 · 17587 问题
相似问题