請(qǐng)問老師,一個(gè)類至少有一個(gè)默認(rèn)的構(gòu)造函數(shù)吧,這個(gè)intetAddress類不存在構(gòu)造函數(shù)的意思是不是因?yàn)椴荒軕{空構(gòu)造一個(gè)新的機(jī)器?
請(qǐng)問老師,一個(gè)類至少有一個(gè)默認(rèn)的構(gòu)造函數(shù)吧,這個(gè)intetAddress類不存在構(gòu)造函數(shù)的意思是不是因?yàn)椴荒軕{空構(gòu)造一個(gè)新的機(jī)器?
2016-04-28
InetAddress對(duì)象的獲取
InetAddress的構(gòu)造函數(shù)不是公開的(public),所以需要通過(guò)它提供的靜態(tài)方法來(lái)獲取,有以下的方法:
static InetAddress[] getAllByName(String host)
static InetAddress getByAddress(byte[] addr)
static InetAddress getByAddress(String host,byte[] addr)
static InetAddress getByName(String host)
static InetAddress getLocalHost()