toString() JAVA – JAVA 10th Class notes – ICSE JAVA Notes

toString() JAVA – JAVA 10th Class notes – ICSE JAVA Notes

toString( ) :

toString( ) function converts the primitive data type to the String type. This conversion is important to apply the string functions on digits of the numbers.


Integer type to String type Conversion :

Syntax : String res = Integer.toString(int);


Example : int n=24;

String str=Integer.toString(n);


Output : 24

Here the Integer Number 24 has got converted to the String 24. Now on this String 24 non of the arithmetic functions can be applied.


/* Program to illustrate the function toString() */



class To_String


public static void main(String args[])throws IOException


BufferedReader br = new BufferedReader(new InputStreamReader(;

System.out.print(” Enter an Integer Digit : “);

int n=Integer.parseInt(br.readLine());

String res = Integer.toString(n);

System.out.println(” Data converted to String : ” + res);



Leave a Reply

Your email address will not be published. Required fields are marked *

Security Code: