慕姐2131086
2018-04-04 22:47
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);
因为第一次是int three=0 是初始化three为0,后面每次在这个int初始化基础上再次对three进行赋值,所以后面不用在加int了,如果加了int,后面再次赋值是在后面你再int基础上进行赋值的
这道题的代码:
int one = 10 ;
int two = 20;
int three = 0 ;
int as=one+two;
int sw=two+two;
int dw=two+two-one;
int ad=(one+two)*one;
int asd=(ad/30)+two;
int sc=(one+two)%(one+two);
System.out.println("three=one+two==>"+as);
System.out.println("three+=one==>"+sw);
System.out.println("three-=one==>"+dw);
System.out.println("three*=one==>"+ad);
System.out.println("three/=one==>"+asd);
System.out.println("three%=one==>"+sc);
three只是个变量名,使用前已经用int定义了,所以再使用的时候不需要再定义了
Java入门第一季(IDEA工具)升级版
1165548 学习 · 17586 问题
相似问题
回答 1
回答 1