毕姥爷说百度不止一台主机,百度的IP地址打印出来不唯一,怎么我打印出来的百度地址.腾讯地址以及新浪地址就一个?这是怎么回事?难道这些服务器都只有一个主机???
import java.net.*;
class IPDemo
{
public static void main(String[] args) throws Exception
{
InetAddress ia1 = InetAddress.getByName("www.baidu.com");
System.out.println("baidu Address:"+ia1.getHostAddress());
System.out.println("baidu name:"+ia1.getHostName());
System.out.println("--------------------------");
InetAddress ia2 = InetAddress.getByName("www.qq.com");
System.out.println("qq Address:"+ia2.getHostAddress());
System.out.println("qq name:"+ia2.getHostName());
System.out.println("--------------------------");
InetAddress ia3 = InetAddress.getByName("www.sina.com.cn");
System.out.println("sina Address:"+ia3.getHostAddress());
System.out.println("sina name:"+ia3.getHostName());
}
}
|
|