
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Value Stored in a Byte as Unsigned Integer in Java
Let us first create signed byte −
byte signedVal = -100;
Now convert a byte to an unsigned integer −
int unsignedVal = Byte.toUnsignedInt(signedVal);
Example
public class Demo { public static void main(String[] args) { byte signedVal = -100; int unsignedVal = Byte.toUnsignedInt(signedVal); System.out.println("Signed value (byte) = " + signedVal); System.out.println("Unsigned value (byte) = " + unsignedVal); } }
Output
Signed value (byte) = -100 Unsigned value (byte) = 156
Advertisements