⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 java的经典例子
💻 JAVA
字号:
import java.math.*;

class Main {
    // Creates a BigInteger object, calls toByteArray() and prints the result.
    static void print(int n) {
        byte[] buf = BigInteger.valueOf(n).toByteArray();

        System.out.print("new byte[]{");
        for (int i=0; i<buf.length; i++) {
            if (i>0) {
                System.out.print(" ,");
            }
            System.out.print("0x"+Integer.toHexString(buf[i]&0xff));
        }
        System.out.println("}");
    }

    public static void main(String[] args) {
        print(0);      // new byte[]{0x0}
        print(1);      // new byte[]{0x1}
        print(-1);     // new byte[]{0xff}
        print(0x80);   // new byte[]{0x0 ,0x80}
        print(-0x80);  // new byte[]{0x80}
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -