String Concatenation

Advertisements

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 Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements