Java.lang.Integer.toString(int i) Method


Description

The java.lang.Integer.toString(int i) method returns a String object representing the specified integer.

Declaration

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

public static String toString(int i)

Parameters

i − This is an integer to be converted.

Return Value

This method returns a string representation of the argument 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(10);
   
      // returns a string representation of the specified integer in base 10
      String retval = i.toString(30);
      System.out.println("Value = " + retval);
   }
} 

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

Value = 30
java_lang_integer.htm
Advertisements