Here you can find the source of removeNull(InetAddress addrs[])
public final static InetAddress[] removeNull(InetAddress addrs[])
//package com.java2s; //License from project: Apache License import java.net.InetAddress; public class Main { public final static InetAddress[] removeNull(InetAddress addrs[]) { int count = 0; for (int i = 0; i < addrs.length; i++) if (addrs[i] != null) count++;//from w ww.j av a 2s. c o m InetAddress[] result = new InetAddress[count]; count = 0; for (int i = 0; i < addrs.length; i++) if (addrs[i] != null) result[count++] = addrs[i]; return result; } }