81Java与网络 例:获取本机的I地址 import java. net. *i public class getlocalHostTest i public static void maino i InetAddress myIP=null; try (mylP=InetAddress.getLocalHosto; catch(UnknowHostException e)t System, out. println(myIp); 创建 inetaddress类不用构造函数(不用new)4 8.1 Java与网络 例:获取本机的IP地址 import java.net.*; public class getLocalHostTest { public static void main() { InetAddress myIP=null; try {myIP=InetAddress.getLocalHost();} catch{UnknowHostException e){} System.out.println(myIP); } } 创建inetAddress类不用构造函数(不用new)