Add byte to int conversion code

This commit is contained in:
anujgaud 2024-01-15 22:31:09 +05:30 committed by GitHub
parent 85c4162119
commit 84530dd8bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,25 @@
package com.baeldung.bytetoint;
public class ByteToIntConversion {
static int usingTypeCasting(byte b){
int i = b;
return i;
}
static int usingIntegerValueOf(byte b){
return Integer.valueOf(b);
}
static int usingByteIntValue(byte b){
Byte byteObj = new Byte(b);
return byteObj.intValue();
}
static int usingMathToIntExact(byte b){
return Math.toIntExact(b);
}
static int usingByteUnsignedInt(byte b){
return Byte.toUnsignedInt(b);
}
}