Check for number by parsing it to integer if it is greater than max number so far
int temp = Integer . parseInt ( String . valueOf ( number . charAt ( i ) ) ) ; if ( temp > max && temp <= n ) max = temp ; }