Write a Java Program to convert int type variables to String

Write a Java Program to convert int type variables to String

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
class Main {
  public static void main(String[] args) {

    // create int variable
    int num1 = 36;
    int num2 = 99;

    // convert int to string
    // using valueOf()
    String str1 = String.valueOf(num1);
    String str2 = String.valueOf(num2);

    // print string variables
    System.out.println(str1);    // 36
    System.out.println(str2);    // 99
  }
}

Final output

Leave a Comment