Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Java-conversion Convert an Integer into a String

Related Tutorials


 
 

Share on Google+Share on Google+

Convert an Integer into a String

Advertisement
In this section, you will learn to convert an integer type data into a string type.

Convert an Integer into a String

     

In this section, you will learn to convert an integer type data into a string type. The java.lang package provides this conversion  functionality through toString() method.

Code Description:

This program takes an integer number at  the console and it converts it into a string format using the Integer(str).toString() method. The given number takes an integer number that must be converted into an string format. The toString() method convert Integer number to string number.

toString():
The toString() method converts an integer value into a String. 

Here is the code of this program:

import java.io.*;
import java.lang.*;

public class  IntegerToString {
  public static void main(String[] argsthrows IOException{
  BufferedReader read = 
 
new BufferedReader(new InputStreamReader(System.in));
  System.out.println("Enter the integer value!");
  String str = read.readLine();
  String s = new Integer(str).toString();
  System.out.println("String:=" +s);
  }
}

Download this program:

Output this program.

C:\corejava>java IntegerToString
Enter the integer value!
24
string: 24
C:\corejava>

 

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 15, 2007

Related Tutorials

Discuss: Convert an Integer into a String   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:10
ravi
March 27, 2011
java question

what will happen if we write static before public in java
pradeep joshi
February 17, 2013
wrong description

http://www.roseindia.net/java/java-conversion/IntegerToString.shtml check it out
Money
January 20, 2012
Integer to string conversion

i need coding for Integer to string conversion....
kuna
January 31, 2012
subj

thanks.......i got solution
irs
February 18, 2012
nothing

<html> <body> hello </body> </html>
Jack
March 3, 2012
Thanks!

Thanks for your helpful tutorial!
Zeeshan
April 11, 2012
Convert an Integer into a String

what an Idiot.... use this String x = String.valueOf(int);
Gaurav
July 20, 2012
java mail query

whenever I am trying to send mail using java program it is showing a "com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. ru10sm2458490pbc.50" error please help me
NaveenReddy Bommu
September 19, 2012
Another approach

int a=10; String s = a+""; system.out.println(s);
ram
December 19, 2012
java

super concept
DMCA.com