- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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 a String to a byte number in Java
Use the parseByte() method in Java to convert a String to a byte.
Let’s say the following is our string −
String str = “76”;
Now, the parseByte() method converts the string to byte −
byte val = Byte.parseByte(str);
The following is an example −
Example
public class Demo { public static void main(String[] args) throws Exception { String str = "76"; byte val = Byte.parseByte(str); System.out.println(val); } }
Output
76
Advertisements