為什么賦值時(shí),three前不加int
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);
2018-05-18
?因?yàn)榈谝淮问莍nt three=0 是初始化three為0,后面每次在這個(gè)int初始化基礎(chǔ)上再次對(duì)three進(jìn)行賦值,所以后面不用在加int了,如果加了int,后面再次賦值是在后面你再int基礎(chǔ)上進(jìn)行賦值的
2018-05-17
這道題的代碼:
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);
2018-04-04
three只是個(gè)變量名,使用前已經(jīng)用int定義了,所以再使用的時(shí)候不需要再定義了