I would like a way to solve a problem consisting of reading 2 user numbers that will be my start and end ex 10 and 50 and within that range do not show the repeated numbers ex 11,22,33,44. p>
I would like a way to solve a problem consisting of reading 2 user numbers that will be my start and end ex 10 and 50 and within that range do not show the repeated numbers ex 11,22,33,44. p>
You could transform this int
to String
and thus compare your substring or even use a regular expression
Something like this:
int inicio = 0;
int fim = 50;
for (int i = inicio; i < fim; i++) {
String check = String.valueOf(i);
if (check.length() > 1) {
if (check.substring(0, 1).equals(check.substring(1, 2))) {
System.out.println(i); //mostro os repetidos
}
}
}