I am new to Java so sorry if this is an easy problem. I am trying to generate a random IP address. I am generating the 4 numbers individually and want to format them like ###.###.###.###
My code is as follows:
static final Random _random = new Random(Integer.parseInt(seed) / 2);
String ip = String.format(
Locale.US,
"###.###.###.###",
_random.nextInt((254 - 1) + 1) + 1,
_random.nextInt((254) + 1),
_random.nextInt((254) + 1),
_random.nextInt((254 - 1) + 1) + 1
);
I am getting the error
too many arguments for format string (found:4, expected:0)
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire