2012-01-06

How to Convert Integer Variable to String in Java

This is the simplest way i found on my experiments in type casting int to String in Java

//initialize a integer type variable
int integerVariable = 4;
//initialize a String type variable
String stringVariable;
//Type Cast int to String
stringVariable=integerVariable="";


is there a simple way than that your comments are really appreciate.

Reactions:

2 අදහස්:

first of all, this is not called casting. Instead it's called converting.
Second of all the code is erroneous, cuz you can't assign a String value what so ever to a int type variable.

The easiest way is, juz assign the int value to String

hmm i tried, but couldn't. anyway thanx for the comment here.

Related Posts Plugin for WordPress, Blogger...