新手上路~不要见笑

public static InetSocketAddressSpecification singleton(InetAddress address,
int port) {
return singleton(new InetSocketAddress(address, port));
} public static InetSocketAddressSpecification singleton(
final InetSocketAddress address) {
return new InetSocketAddressSpecification() {
public Iterator iterator() {
return IteratorUtils.singletonIterator(address);
}
};

}

解决方案 »

  1.   

    接口也可以new ?(InetSocketAddressSpecification是一个接口)在return调用函数,最后得到return的数据就是 IteratorUtils.singletonIterator(address);?
      

  2.   

    public static InetSocketAddressSpecification singleton(
    final InetSocketAddress address) 
    方法返回的是
    new InetSocketAddressSpecification() {
      public Iterator iterator() {
         return IteratorUtils.singletonIterator(address);
      }
    }
      

  3.   

    哦,itrator 是实现接口的方法。public Iterator iterator() {
    return IteratorUtils.singletonIterator(address);
      

  4.   

    返回的是InetSocketAddress类型的对象。