日期:2014-05-20  浏览次数:20663 次

10,11,12,13,14,15的数组问题,有个问题不记得问了?
import   java.util.ArrayList;

class   ComHex{
void   comHex(String   scrString){
ArrayList   hexNum   =   new   ArrayList();
char[]   a   =   scrString.toCharArray();
for(int   i   =   0;   i   <   a.length;   i++){
if( 'a '==a[i])
hexNum.add(10);
else   if( 'b '==a[i])
hexNum.add(11);
else   if( 'c '==a[i])
hexNum.add(12);
else   if( 'd '==a[i])
hexNum.add(13);
else   if( 'e '==a[i])
hexNum.add(14);
else   if( 'f '==a[i])
hexNum.add(15);
else
hexNum.add(a[i]);
}
for(int   n   =   0;   n   <   a.length;   n++)
System.out.println(hexNum.get(n));
}
}

public   class   Hex   {
public   static   void   main(String[]   args){
ComHex   scr   =   new   ComHex();
scr.comHex( "abcdef ");
}
}


现在得到的hexNum数组类型是字符窜的,怎么把数组类型转换为整数类型数组?

------解决方案--------------------
'1 '的unicode是0x31,就是49
减去48就是1