
- Java.lang Package classes
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package extras
- Java.lang - Interfaces
- Java.lang - Errors
- Java.lang - Exceptions
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java.lang.Byte.valueOf() Method
Description
The java.lang.Byte.valueOf(String s) returns a Byte object holding the value given by the specified String. The argument is interpreted as representing a signed decimal byte, exactly as if the argument were given to the parseByte(java.lang.String) method.
The result is a Byte object that represents the byte value specified by the string.
Declaration
Following is the declaration for java.lang.Byte.valueOf() method
public static Byte valueOf(String s)throws NumberFormatException
Parameters
s − the string to be parsed
Return Value
This method returns a Byte object holding the value represented by the string argument.
Exception
NumberFormatException − If the String does not contain a parsable byte.
Example
The following example shows the usage of lang.Byte.valueOf() method.
package com.tutorialspoint; import java.lang.*; public class ByteDemo { public static void main(String[] args) { // create a String s and assign value to it String s = "+120"; // create a Byte object b Byte b; /** * static method is called using class name. * assign Byte instance value of s to b */ b = Byte.valueOf(s); String str = "Byte value of string " + s + " is " + b; // print b value System.out.println( str ); } }
Let us compile and run the above program, this will produce the following result −
Byte value of string +120 is 120
java_lang_byte.htm
Advertisements