Pages

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.

2 අදහස්:

  1. 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

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

    ReplyDelete

මෙම ලිපිය කියවනකොට හිතුණු දේවල් වලින් ටිකක් මෙතන ලියලම යන්නකෝ