Number intValue() in Java

intValue(): This method is available in java.lang.Number of Java.

Syntax:

int java.lang.Number.intValue()

This method returns the value of the specified number as an int.

Parameters: NA

Returns: the numeric value represented by this object after conversion to type int.

Exceptions: NA

Approach

Java

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

        Number number = 123;
        System.out.println(number.intValue());
    }
}

Output:

123

No comments:

Post a Comment