Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Java Program to concatenate a String and Integers
To concatenate a String and some integer values, you need to use the + operator.
Let?s say the following is the string.
String str = "Demo Text";
Now, we will concatenate integer values.
String res = str + 1 + 2 + 3 + 4 + 5;
The following is the final example.
Example
public class Demo {
public static void main(String[] args) {
String str = "Demo Text";
System.out.println("String = "+str);
String res = str + 1 + 2 + 3 + 4 + 5;
System.out.println(res);
}
}
Output
String = Demo Text Demo Text12345
Advertisements
