Number toString() in Java

toString(): This method is available in java.lang.Object class of Java.

Syntax:

String java.lang.Object.toString()

This method returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object.

Parameters: NA

Returns: a string representation of the object.

Exceptions: NA

Approach

Java

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

        Number number = 1234;
        System.out.println(number.toString());
    }
}

Output:

1234

No comments:

Post a Comment