Notice: session_start(): A session had already been started - ignoring in /home/u614325693/domains/onedoubt.com/public_html/post.php on line 3
Java String Concatenation - ONEDOUBT.COM

String Concatenation

The + operator can be used between strings to combine them. This is called concatenation:

Example

String firstName = "John";
String lastName = "Doe";
System.out.println(firstName + " " + lastName);

Note that we have added an empty text (" ") to create a space between firstName and lastName on print.

You can also use the concat() method to concatenate two strings:

Example

String firstName = "John ";
String lastName = "Doe";
System.out.println(firstName.concat(lastName));

 


Login
ADS CODE