Java.lang.Integer.toString() Method

Advertisements


Description

The java.lang.Integer.toString() method returns a String object representing this Integer's value.

Declaration

Following is the declaration for java.lang.Integer.toString() method

public String toString()

Parameters

  • NA

Return Value

This method returns a string representation of the value of this object in base 10.

Exception

  • NA

Example

The following example shows the usage of java.lang.Integer.toString() method.

package com.tutorialspoint;

import java.lang.*;

public class IntegerDemo {

   public static void main(String[] args) {

     Integer i = new Integer(20);
   
     // returns a string representation of the integer value in base 10
     String retval = i.toString();
     System.out.println("Value = " + retval);
   }
}

Let us compile and run the above program, this will produce the following result:

Value = 20



Advertisements
Advertisements