提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
根据子网的划分方式增加子网,例如。
/** * Copyright 2012 InCNTRE, This file is released under Apache 2.0 license except for component libraries under different licenses http://www.apache.org/licenses/LICENSE-2.0 */ //package com.nowjava; /** 来 自 N o w J a v a . c o m **/ public class Main { public static void main(String[] argv) throws Exception { int ip = 2; int subnet = 2; System.out.println(incrementSubnet(ip, subnet)); } /** * Increment subnet based on how subnets are to be divided * e.g. 192.168.0.0/24 will incremented will be * 192.168.1.0/24 * @param ip * @param subnet * @return the incremented subnet in integer form */ public static int incrementSubnet(int ip, int subnet) { int newIP = 0;