Casting in Java

Casting means to treat or convert a number from one type to another.

(byte) (maxByte /2);

public class Primitive {
    public static void main(String[] args) {

        byte maxByte = Byte.MAX_VALUE;
        byte a = (byte) (maxByte / 2);
        System.out.println(a);
    }
}
63

Leave a Reply

Your email address will not be published.

ANOTE.DEV