第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

關(guān)于靜態(tài)方法

為什么我直接調(diào)用靜態(tài)方法會(huì)報(bào)錯(cuò)

package com.Wujin;


public class Tel {

? ?String name;

? ?int no;

? ?static String ?num;

? ?// public Tel(){} ? //無參構(gòu)造方法

? ?public Tel(){name="yexiaoxia";} ?//有參構(gòu)造方法

? ?

? ?{

? no=10; ? ? ? ? ? ? ? //普通初始化模塊

? ?}

? ?

? ?static

? ?{

? num="5685968"; ? ? ? ? ? ? ? //靜態(tài)初始化模塊

? ?}

? ?

? ?public void print(){ ? ? ? ? ? ? ? ? ?//普通方法

? System.out.println(name);

? System.out.println(num);

? ?}

? ?

? ?public static void show() ? ? ? ? ? //靜態(tài)方法

? ?{

? System.out.println(num);

? Tel a=new Tel();

? System.out.println(a.name);

? ?}

? ?

}


package com.Wujin;


public class Wu {


public static void main(String[] args) {

// TODO Auto-generated method stub

Tel hello = new Tel();

hello.print();

Tel.show();

show();

}


}


正在回答

2 回答

在同一個(gè)類中,可以直接訪問類中的靜態(tài)方法。不在同一個(gè)類中需要類名.方法名或者對(duì)象.方法名來實(shí)現(xiàn)調(diào)用。

0 回復(fù) 有任何疑惑可以回復(fù)我~
Tel?hello?=?new?Tel();
hello.print();//正確
Tel.show();//正確
show();//這個(gè)show()方法在哪?除了這一行完全正確


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

慕標(biāo)5802213 提問者

靜態(tài)方法不是可以直接調(diào)用么
2015-07-27 回復(fù) 有任何疑惑可以回復(fù)我~
#2

wswzh0329 回復(fù) 慕標(biāo)5802213 提問者

。。前提是要在同一個(gè)類中
2015-10-03 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

關(guān)于靜態(tài)方法

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

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

幫助反饋 APP下載

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

公眾號(hào)

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