?? net1.java
字號(hào):
package net;
/*第1題*/
import java.net.*;
public class Net1 {
public static void main(String args[])
{
try{
InetAddress address=InetAddress.getByName("www.baidu.com");
System.out.println(address.toString());
String domain=address.getHostName();
System.out.println(domain);
String ip=address.getHostAddress();
System.out.println(ip);
InetAddress address1=InetAddress.getByName("59.53.0.1");
System.out.println(address1.toString());
InetAddress address2=InetAddress.getLocalHost();/*獲取本機(jī)的域名和IP */
String domain1=address2.getHostName();
System.out.println(domain1);
String ip1=address2.getHostAddress();
System.out.println(ip1);
}catch(UnknownHostException e){System.out.print("無法找到地址");}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -