Convert a signed byte to an int - Java java.lang

Java examples for java.lang:byte Array Convert

Description

Convert a signed byte to an int

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        byte b = 2;
        System.out.println(signedByteToInt(b));
    }//from w  ww  .j a  va  2  s.c  o  m

    /**
     * Convert a signed byte to an int
     */
    public static int signedByteToInt(byte b) {
        return (int) b;
    }
}

Related Tutorials