Tuesday, May 21, 2013

how to convert an int to string in java

Say int i = 10;

and String compare = "10";----Value from the Program

You can use either of these

1) Integer.toString(i)

                or

2)String.valueOf(i)

(i.e)

String convertedValue = Integer.toString(i);


if(convertedValue.equals(compare)){
----------Which turns out to be true
}
 

No comments:

Post a Comment