private static int[] values = {8, 6, 14, 24, 2}; //
public static int index = -1;
public static int count() {
return values[++index % values.length];
}
System.out.println(count())
这就是我用来做常规数字的方法,但是当我开始使用121.12.23.4之类的IP地址时,它是行不通的。显然是因为它不是int,但我想知道如何使用IP地址。
有帮助吗?
private static String[] ips = {"121.2.4.10","192.153.4.8","221.2.3.1"}; //
public static int index = -1;
public static String next() {
return ips[++index % ips.length];
}
System.out.println(next());