public class Main { public static void main(String args[]) { byte b1 = 127; System.out.println(b1); System.out.println(unsignedByteToInt(b1)); } public static int unsignedByteToInt(byte b) { return (int) b & 0xFF; } }