1
我在检查java.net.InetAddress
类的源文件,发现很少有方法总是返回false。例如为什么Java源代码中的InetAddress.isSiteLocalAddress()总是返回false
/**
* Utility routine to check if the InetAddress is a site local address.
*
* @return a <code>boolean</code> indicating if the InetAddress is
* a site local address; or false if address is not a site local unicast address.
* @since 1.4
*/
public boolean isSiteLocalAddress() {
return false;
}
我错过了什么吗?为什么我们需要一个总是返回false的方法?在这个类中以'is'开头的所有方法都是一样的。请参阅http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/net/InetAddress.java
谢谢!我已经检查 - Inet4Address和Inet6Address扩展InetAddress并重写了所有这些方法。 – Sundeep