Byte Class Fields in Java with example - GeeksforGeeks

12 Oct, 2018
Byte class is a wrapper class for the primitive type byte which contains several methods to effectively deal with a byte value like converting it to a string representation, and vice-versa. An object of Byte class can hold a single byte value.
Byte class offers four constants in the form of Fields. These are:
MAX_VALUE:The MAX_VALUE is a instance variable of Byte class which is used to return the maximum byte value.Syntax:public static final byte MAX_VALUEUsage:Byte.MAX_VALUEReturn Value: It returns a byte value equal to 127.Below is the implementation of MAX_VALUE:// Java code to implement// MAX_VALUE of Byte class  class GFG {    public static void main(String[] args)    {          // byte variable        byte max_value;          // MAX_VALUE Byte class        max_value = Byte.MAX_VALUE;          // printing the MAX_VALUE        System.out.println(max_value);    }}Output:127

Syntax:
public static final byte MAX_VALUE
Usage:
Byte.MAX_VALUE
Return Value: It returns a byte value equal to 127.
Below is the implementation of MAX_VALUE:
// Java code to implement// MAX_VALUE of Byte class  class GFG {    public static void main(String[] args)    {          // byte variable        byte max_value;          // MAX_VALUE Byte class        max_value = Byte.MAX_VALUE;          // printing the MAX_VALUE        System.out.println(max_value);    }}
127

MIN_VALUE:The MIN_VALUE is a instance variable of Byte class which is used to return the minimum byte value.Syntax:public static final byte MIN_VALUEUsage:Byte.MIN_VALUEReturn Value: It returns a byte value equal to -128.Below is the implementation of MIN_VALUE:// Java code to implement// MIN_VALUE of Byte class  class GFG {    public static void main(String[] args)    {          // byte variable        byte min_value;          // MIN_VALUE Byte class        min_value = Byte.MIN_VALUE;          // printing the MIN_VALUE        System.out.println(min_value);    }}Output:-128

Syntax:
public static final byte MIN_VALUE
Usage:
Byte.MIN_VALUE
Return Value: It returns a byte value equal to -128.
Below is the implementation of MIN_VALUE:
// Java code to implement// MIN_VALUE of Byte class  class GFG {    public static void main(String[] args)    {          // byte variable        byte min_value;          // MIN_VALUE Byte class        min_value = Byte.MIN_VALUE;          // printing the MIN_VALUE        System.out.println(min_value);    }}
-128

SIZE:The SIZE is a instance variable of Byte class which is used to return number of bits required to represent a byte value in binary representation (two’s complement).Syntax:public static final int SIZEUsage:Byte.SIZEReturn Value: It returns a int value equal to 8.Below is the implementation of SIZE:// Java code to implement// SIZE of Byte class  class GFG {    public static void main(String[] args)    {          // SIZE Byte class        int output = Byte.SIZE;          // printing the output        System.out.println(output);    }}Output:8

Syntax:
public static final int SIZE
Usage:
Byte.SIZE
Return Value: It returns a int value equal to 8.
Below is the implementation of SIZE:
// Java code to implement// SIZE of Byte class  class GFG {    public static void main(String[] args)    {          // SIZE Byte class        int output = Byte.SIZE;          // printing the output        System.out.println(output);    }}
8

TYPE: The TYPE is a instance variable of Byte class which is used to return Class instance representing the primitive data type byte.Syntax:public static final Class<Byte> TYPEUsage:Byte.TYPEReturn Value: It returns an Class instance representing the primitive data type byte.Below is the implementation of TYPE:// Java code to implement// TYPE of Byte class  class GFG {    public static void main(String[] args)    {          // TYPE variable of Byte class        Class<Byte> output = Byte.TYPE;          // printing the output        System.out.println(output);    }}Output:byte

Syntax:
public static final Class<Byte> TYPE
Usage:
Byte.TYPE
Return Value: It returns an Class instance representing the primitive data type byte.
Below is the implementation of TYPE:
// Java code to implement// TYPE of Byte class  class GFG {    public static void main(String[] args)    {          // TYPE variable of Byte class        Class<Byte> output = Byte.TYPE;          // printing the output        System.out.println(output);    }}
byte

Java-Byte
Java-Class and Object
Java-Library
Java
Java-Class and Object
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Initialize an ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Multidimensional Arrays in Java
Stack Class in Java
Stream In Java
Singleton Class in Java