50,759
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args){
String[] ipAddrs = {"192.168.1.1", "192.168.1.2"};
int[] segments = new int[255];
Arrays.fill(segments, 0);
for(String ipa : ipAddrs){
int lastSegment = Integer.parseInt(ipa.substring(ipa.lastIndexOf(".")));
segments[lastSegment] = 1;
}
for(int i = 1; i<segments.length; i++){
if(segments[i] == 0){
System.out.println("Segment " + i + " is missing");
}
}
}