static InetAddress getByName(String host)
      Determines the IP address of a host, given the host's name.String getHostAddress()
      Returns the IP address string in textual presentation.

解决方案 »

  1.   

    第一個怎麽會返回pc19?
    static InetAddress getByName(String host)這個是通過主機名得到地址
         
    String getHostAddress()這個是得到地址的字符串表示應該用這個啦
    String getHostName() 
              Gets the host name for this IP address 
      

  2.   

    真对不起,我一激动就打错了,正确的问题是:为什么:System.out.println(InetAddress.getByName("192.168.1.19").getByName())返回:pc19但System.out.println(InetAddress.getByName("192.168.1.16").getByName())
    却返回不了 pc16但我在DOS下: ping pc16
    却返回 192.168.1.16pc16和pc19都和我在同一个局域网的,我通过局域网都可以访问这两台电脑。真不知问题出在哪里???
      

  3.   

    getByName(String) 
    给定主机名,确定该主机的所有 IP 地址。
      

  4.   

    你用getAllByName(pc16) 看该主机是否有多个ip,看和他有没有关系