Integer to string java

www.lautt‮‬uri.com
Integer to string java

In Java, you can convert an Integer object to a String using the toString() method of the Integer class or by using string concatenation.

Here is an example of how to convert an Integer to a String using the toString() method:

Integer number = 42;
String str = number.toString();  // str is "42"

This method returns a new String object that contains the String representation of the Integer value.

You can also use string concatenation to convert an Integer to a String:

Integer number = 42;
String str = "" + number;  // str is "42"

This method involves creating a new String object for each concatenation, so it is not as efficient as the toString() method.

For more information on converting data types in Java, you can refer to the Java documentation.

Created Time:2017-11-01 22:29:44  Author:lautturi