String Concatenation


Prev Tutorial Next Tutorial

String Concatenation

There are two way to concat string object in java:

  • By + (string concatenation) operator
  • By concat() method

By + operator

Using Java string concatenation operator (+) you can combined two or more strings.

Example

class StringHandling
{
public static void main(String arg[])
{
String s= "Java" + "Code"; 
System.out.println(s);
}
}

Output

JavaCode

By concat() method

concat() method is used to combined two strings.

Example

class StringHandling
{
public static void main(String arg[])
{
String s1="Java";
String s2="Code";
String s3=s1.concat(s2);
System.out.println(s3);
}
}

Output

JavaCode

Prev Tutorial Next Tutorial

Advertisements
Download Projects

Advertisements

Download WhatsApp Status Video

Buy This Ad Space Only $50 per Month, Ad Size 300X250 Contact on: [email protected] WhatsApp no. 8882538826

Google Adsense Advertisements