- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert Byte to numeric primitive data types in Java
To convert Byte to numeric primitive data types, use the following methods −
byteValue() shortValue() intValue() longValue() floatValue()
Firstly, let us declare a Byte.
Byte byteVal = new Byte("35");
Now, let us see how to convert it to long type, for a simple example.
long longVal = byteVal.longValue(); System.out.println(longVal);
In the same way, you can convert it to other primitive data types as shown in the complete example below −
Example
public class Demo { public static void main(String args[]) { // byte Byte byteVal = new Byte("35"); byte b = byteVal.byteValue(); System.out.println(b); short shortVal = byteVal.shortValue(); System.out.println(shortVal); int intVal = byteVal.intValue(); System.out.println(intVal); long longVal = byteVal.longValue(); System.out.println(longVal); float floatVal = byteVal.floatValue(); System.out.println(floatVal); double doubleVal = byteVal.doubleValue(); System.out.println(doubleVal); } }
Output
35 35 35 35 35.0 35.0
- Related Articles
- Convert Long to numeric primitive data types in Java
- Convert Short to numeric primitive data types in Java
- Java Program to convert Double to numeric primitive data types
- Java Program to convert Java Float to Numeric Primitive Data Types
- Convert byte primitive type to Byte object in Java
- List out the default values of numeric and non-numeric primitive data types in Java?
- Java primitive data types
- How to convert JavaScript objects to primitive data types manually?
- What are primitive data types in Java?
- Default value of primitive data types in Java
- Java Program to convert a string into a numeric primitive type using Integer.valueOf()
- C++ Program to convert primitive types to objects
- How to convert primitive data into wrapper class using Java?
- What are Primitive and Non-Primitive Data Types in JavaScript?
- Uninitialized primitive data types in C/C++

Advertisements