Click to See Complete Forum and Search --> : get the number like this 99,1221,


ajaxer
12-18-2007, 04:04 AM
get the number like this 99,.....151....1001....2332 between 100 to 1000
thanks for help

potterd64
12-19-2007, 02:45 PM
Well first I want to say you should really explain your questions more. Second, you could do something like this.


ArrayList numbers = new ArrayList();
for (int i=101; i<1000; i++){
String number = Integer.toString(i);
if (number.length == 3){

if (number.charAt(0) == number.charAt(2)){
numbers.add(number);
}

}
}


and all your numbers will be in the numbers ArrayList. Of course this wouldn't handle 4 digit numbers...

For numbers with an even number of digits you would want to split the number in two, reverse one of the halves, and see if they're equal. You can figure that out since this sounds like a homework question!