toHexString

 public static String toHexString(int num){
  int sc = 0xF;
  int length = 0;
  char[] cs1 = new char[Integer.SIZE/4];
  do{
    int temp = num & sc;
    num >>= 4;
    cs1[length] =
      (char)(temp >= 10 ? temp-10+'A' : temp+'0');
    length ++;
  }while( num > 0);
  System.out.println(length);
  char[] cs2 = new char[length];
  for(int i=0;i    cs2[i] = cs1[length-1-i];  
  }
  
  
  
  return new String(cs2);
 }
}

你可能感兴趣的:(toHexString)