((type.charAt(0) - 48) << 12) | ((type.charAt(1) - 48) << 8)
| ((type.charAt(2) - 48) << 4) | (type.charAt(3) - 48);
char

解决方案 »

  1.   

    type是字符串吧?
    截取第一位的char。
    char都是有对应的数字编码的
    char对应的数字码减去48,
    然后进行移位运算,左移12位,就是等于这个数乘以2的12次方。
    这什么玩意,想实现啥效果。。
      

  2.   

    char可以升级为int 然后再移位
      

  3.   

    楼主基础不扎实,char其实占2个字节,说白了就是一个short的整数,-48后自动转型为int,再移位
      

  4.   


    是的,我很少接触什么位移,流,byte之类的,概念都不清楚,不知道怎么补
      

  5.   


    /** Parses a message type expressed as a hex string and returns the integer number.
     * For example, "0200" or "200" return the number 512 (0x200) */
      

  6.   


    char升级为int怎么理解,晕啊