- class Demo
- {
- public static void main(String[] args)
- {
- Demo_method t = new Demo_method();
- System.out.println(t.show(3280));//结果为 11010000
- }
- }
- class Demo_method
- {
- String show(int a)
- {
- return Integer.toBinaryString(a & 0xff);//通过和oxff与运算得到后8位。Interger.toBinaryString()转换成2进制、
- }
- }
复制代码 |