class Test {
public static void main(String[] args){
byte byCount = 0xa0;
System.out.println(byCount);
}
}把你的程序编译有错误啊
D:\JCreator Pro\MyProjects\safds.java:6: possible loss of precision
found : int
required: byte
byte byCount = 0xa0;
^
1 errorProcess completed.
byte byCount = (byte)0xa0;
public static void main(String[] args){
byte byCount = (byte)0xa0;
System.out.println(Integer.toHexString((int)byCount).substring(6,8));
}
}这样子可不可以?
先Integer.toHexString((int))给一个String后,判断String的长度,
如果是1的话,前面加上System.out.print(0 + strTmp);
如果长度不是1的话,就利用substring进行相应的输出