最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

最后的pri2 hello2=new pri2()是怎么運(yùn)行的?

package com.imooc;

public class pri2{
?? ?int num1;
?? ?int num2;
?? ?static int num3;
?? ?public pri2(){
?? ??? ?num1=91;
?? ??? ?System.out.println("通過構(gòu)造方法為變量num1賦值");
?? ??? ?}
?? ??? ?{
?? ??? ??? ?num2=74;
?? ??? ??? ?System.out.println("通過初始化模塊為num2賦值");
?? ??? ?}
?? ??? ?static{
?? ??? ??? ?num3=83;
?? ??? ??? ?System.out.println("通過靜態(tài)初始化模塊為怒目賦值");
?? ??? ?}
?? ??? ?public static void main(String[] args) {
?? ??? ??? ?pri2 hello=new pri2();
?? ??? ??? ?System.out.println("num1:"+hello.num1);
?? ??? ??? ?System.out.println("num2:"+hello.num2);
?? ??? ??? ?System.out.println("num3:"+num3);
?? ??? ??? ?pri2 hello2=new pri2();
?? ??? ?}
?? ?}

正在回答

2 回答

pri2 hello=new pri2();
?? ??? ??? ?System.out.println("num1:"+hello.num1);
?? ??? ??? ?System.out.println("num2:"+hello.num2);
?? ??? ??? ?System.out.println("num3:"+num3);
?? ??? ??? ?pri2 hello2=new pri2();

這些代碼等同于

pri2 hello=new pri2();

?pri2 hello2=new pri2();

?? ??? ??? ?System.out.println("num1:"+hello.num1);
?? ??? ??? ?System.out.println("num2:"+hello.num2);
?? ??? ??? ?System.out.println("num3:"+num3);

num3屬于靜態(tài)類只能被執(zhí)行一次,所以執(zhí)行結(jié)果缺少“”通過靜態(tài)初始化塊初始化? num3“ ? ? ? ??

0 回復(fù) 有任何疑惑可以回復(fù)我~

Static修飾的類成員,它的使用完全獨(dú)立于該類的任何對象。Static塊僅在該類被加載時(shí)執(zhí)行一次。

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

Chen十八 提問者

非常感謝!
2017-04-22 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

最后的pri2 hello2=new pri2()是怎么運(yùn)行的?

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號