亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么賦值時,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);

正在回答

3 回答

?因為第一次是int three=0 是初始化three為0,后面每次在這個int初始化基礎上再次對three進行賦值,所以后面不用在加int了,如果加了int,后面再次賦值是在后面你再int基礎上進行賦值的

1 回復 有任何疑惑可以回復我~

這道題的代碼:

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);

1 回復 有任何疑惑可以回復我~

three只是個變量名,使用前已經用int定義了,所以再使用的時候不需要再定義了

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么賦值時,three前不加int

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號