How can we convert an integer to a string in Java?
In Java, there are two ways to convert integers to strings:
- Convert integer to string
int num = 123;
String str = Integer.toString(num);
- Convert to string.
int num = 123;
String str = String.valueOf(num);
Both methods can convert integers into their corresponding strings.