📄 netdemo.java
字号:
import java.net.*;
public class NetDemo {
public static void main(String[] args) {
InetAddress ip=null;
try{
ip=InetAddress.getByName("www.sise.com.cn");
System.out.println("主机IP地址:"+ip.getHostAddress());
System.out.println("主机名和IP地址:"+InetAddress.getLocalHost().getHostName()+" "+InetAddress.getLocalHost().getHostAddress());
}catch(UnknownHostException e){}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -