Pages

Combine String

Complete source code below will show you, how to combine two String using + symbol and concat() method from String class.

**************************************************************************
COMPLETE SOURCE CODE FOR : CombineString.java
**************************************************************************


public class CombineString
{
public static void main(String[]args)
{
String a="Hello ";
String b="world";

//First Technique : Using + symbol
String c=a+b;

//Second Technique : Using concat() method from String class
String d=a.concat(b);

//Now we will print result. It should be same.
System.out.println(c);
System.out.println(d);
}
}


**************************************************************************
JUST COMPILE AND EXECUTE IT
**************************************************************************
Related Posts Plugin for WordPress, Blogger...