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

Google Advertisements
Download Projects

Google Adsense Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 300X250 Contact on: hitesh.xc@gmail.com WhatsApp no. 8882538826

Yahoo Advertisements