I must display all server names in the range of v10000 up to v10500.
Below is the code that I tried, but sometimes it displays a zero.
String template = "v10"; int count = 0; while (count < 501) { String number; if (count < 100) { number = "00" + Integer.toString(count); } else if(count < 10) { number = "0" + Integer.toString(count); } else { number = Integer.toString(count); } String server = template + number; System.out.println(server); count++; } But when I show this solution to my boss, he just laughs and says:
I can do this better.
How can I alter my code to make it work properly? I'm new to Java.
count < 10being on top andcount < 100being on bottom