@@ -0,0 +1,1973 @@
+package org.egorlitvinenko.other;%0A%0Aimport java.nio.ByteBuffer;%0A%0A/**%0A *%0A * https://docs.oracle.com/javase/specs/jls/se11/html/jls-3.html#jls-3.10.1%0A * https://docs.oracle.com/javase/specs/jls/se11/html/jls-4.html#jls-4.2.1%0A * https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-2.html#jvms-2.11.1%0A *%0A * **/%0Apublic class ByteCoercion %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        byte a = -83;%0A        int b = a;%0A        byte c = (byte) b;%0A//        int d = 0x800000CD;%0A        int d = 0x8000004D;%0A        byte e = (byte) d;%0A        System.out.println(%22a = %22 + a);%0A        System.out.println(%22b = %22 + b);%0A        System.out.println(%22c = %22 + c);%0A        System.out.println(%22b as binary: %22 + Integer.toBinaryString(b));%0A        System.out.println(%22b as bytes:%22); print(intToByteArray(b));%0A        System.out.println(%22b as bytesBB:%22); print(intToByteArrayBB(b));%0A        System.out.println(%22d = %22 + d);%0A        System.out.println(%22e = %22 + e);%0A        System.out.println(%22d as binary: %22 + Integer.toBinaryString(d));%0A        System.out.println(%22d as bytes:%22); print(intToByteArray(d));%0A        System.out.println(%22d as bytesBB:%22); print(intToByteArrayBB(d));%0A    %7D%0A%0A    private static void print(byte%5B%5D array) %7B%0A        StringBuilder sb = new StringBuilder();%0A        sb.append(%22array=(%22);%0A        for (int i = 0; i %3C array.length; i++) %7B%0A            sb.append(array%5Bi%5D).append(%22,%22);%0A        %7D%0A        sb.deleteCharAt(sb.length() - 1).append(%22)%22);%0A        System.out.println(sb);%0A    %7D%0A%0A    private static byte%5B%5D intToByteArray(int a) %7B%0A        byte%5B%5D result = new byte%5B4%5D;%0A        result%5B0%5D = (byte) (a & 0x000000FF);%0A        result%5B1%5D = (byte) ((a & 0x0000FF00) %3E%3E 8);%0A        result%5B2%5D = (byte) ((a & 0x00FF0000) %3E%3E 16);%0A        result%5B3%5D = (byte) ((a & 0xFF000000) %3E%3E 24);%0A        return result;%0A    %7D%0A%0A    private static byte%5B%5D intToByteArrayBB(int a) %7B%0A        ByteBuffer bb = ByteBuffer.allocate(4);%0A        bb.putInt(a);%0A        return bb.array();%0A    %7D%0A%7D%0A

Add example with byte int manipulations