BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Java int to String Conversion With Examples

Last Updated: November 15, 2022 by Chaitanya Singh | Filed Under: java

In this guide, you will learn how to convert an int to string in Java. We can convert int to String using String.valueOf() or Integer.toString() method. We can also use String.format() method for the conversion.

1. Convert int to String using String.valueOf()

String.valueOf(int i) method takes integer value as an argument and returns a string representing the int argument.

Method signature:

public static String valueOf(int i)

Parameters:
i – integer that needs to be converted to a string

Returns:
A string representing the integer argument

Let’s see the java program:

public class JavaExample {
  public static void main(String args[]) {
    int ivar = 111;
    String str = String.valueOf(ivar);
    System.out.println("String is: "+str);
    //output is: 555111 because the str is a string
    //and the + would concatenate the 555 and str
    System.out.println(555+str);
  }
}

Output: