提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
生成10.0.0.0/8范围内的随机ipv4地址。
/* 来自 nowjava*/ //package com.nowjava; public class Main { public static void main(String[] argv) throws Exception { System.out.println(getRandomIpv4Address()); } /** * Generate a random ipv4 address in the 10.0.0.0/8 range. * @return A string form of the ipv4 address in the 10.0.0.0/8 range. */ public static String getRandomIpv4Address() { return "10." + (int) (Math.random() * 255) + "." + (