tanglimei
public class ArrayTest3 {
	public static void main(String[] args){
		System.out.println(toHex(60));
	}
	
    //将十进制转为16进制 public static String toHex(int num){ char[] chs = new char[8];//定义容器,存储的是字符,长度为8.一个整数最多8个16进制数 int index = chs.length-1; for(int i = 0;i<8;i++) { int temp = num & 15; if(temp > 9){ chs[index] = ((char)(temp-10+\'A\')); }else { chs[index] = ((char)(temp+\'0\')); } index--; num = num >>> 4; } return toString(chs); } //将数组转为字符串 public static String toString(char[] arr){ String temp = ""; for(int i = 0;i<arr.length;i++){ temp = temp + arr[i]; } return temp; } }

  

分类:

技术点:

相关文章:

  • 2021-12-05
  • 2021-12-20
  • 2021-11-07
  • 2021-11-01
  • 2021-12-10
  • 2021-10-19
  • 2021-10-17
  • 2021-11-05
猜你喜欢
  • 2021-12-01
  • 2021-12-01
  • 2021-12-06
  • 2021-12-06
  • 2021-10-12
  • 2021-11-06
  • 2021-11-04
相关资源
相似解决方案