English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Concatenate String to int Value in Java

To concatenate strings as an int value, use the concatenation operator.

This is our int.

int val = 3;

Now, to concatenate a string, you need to declare a string and use+Operators.

String str = "Demo" + val;

Now let's look at another example.

Example

import java.util.Random;
public class Demo {
   public static void main( String args[] ) {
      int val = 3;
      String str = "" + val;
      System.out.println(str + "= Rank ");
   }
}

Output Result

3 = Rank