这样就能编译通过了import java.net.*;
class InetAddressDemo
{
public static void main(String[] args){
String host="localhost";
if(args.length==1)
host=args[0];
InetAddress ia = null;
try{
ia = InetAddress.getByName(host);
}catch(Exception e){}
//是否正确?
System.out.println("Canonical Host Name="+ia.getCanonicalHostName());//canonical 规则的
//ia是否没有getCanonicalHostName()的方法
System.out.println("Host Address="+ia.getHostAddress());
System.out.println("Host Name="+ia.getHostName());
System.out.println("Is Loopback Address="+ia.isLoopbackAddress());//有isLoopbackAddress()方法吗?
}
}
class InetAddressDemo
{
public static void main(String[] args){
String host="localhost";
if(args.length==1)
host=args[0];
InetAddress ia = null;
try{
ia = InetAddress.getByName(host);
}catch(Exception e){}
//是否正确?
System.out.println("Canonical Host Name="+ia.getCanonicalHostName());//canonical 规则的
//ia是否没有getCanonicalHostName()的方法
System.out.println("Host Address="+ia.getHostAddress());
System.out.println("Host Name="+ia.getHostName());
System.out.println("Is Loopback Address="+ia.isLoopbackAddress());//有isLoopbackAddress()方法吗?
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货