public String convertB(int num){
  int mask=15;
  StringBuffer sb=new StringBuffer();
  while (num != 0) {
    int index=(num & mask);
    char c=(char)((index < 10) ? (index + '0') : ('a' + index - 10));
    sb.append(c);
    num=num >>> 4;
  }
  sb.reverse();
  return sb.toString();
}

public String convertB ( int num ) { int mask = 15 ; StringBuffer sb = new StringBuffer ( ) ; while ( num != 0 ) { int index = ( num & mask ) ; char c = ( char ) ( ( index < 10 ) ? ( index + '0' ) : ( 'a' + index - 10 ) ) ; sb . append ( c ) ; num = num > > > 4 ; } sb . reverse ( ) ; return sb . toString ( ) ; }
using bit mask and bit - wise operation
