We are moved to new domain
Click -> www.ehowtonow.com
Friday, 8 May 2015

String Concatenation in Java

Following example shows String concatenation in Java using + operator and StringBuffer.append() method.

Sample Program

package com.javatutorialcorner.javastring;

public class StringConcatenation {

public static void main(String[] args) {
String plusOperator = "Java tutorials corner "
+ " contains tutorials for Java programers day to day needs tutorials"
+ " like Java, Spring, Hibernate, String, JSON, Jackson, GSON,"
+ " XML parsing, Web Service, SOAP Web Service, RESTful Web Service";

System.out.println("plusOperator : " + plusOperator);

StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("Java tutorials corner ");
stringBuffer
.append(" contains tutorials for Java programers day to day needs tutorials");
stringBuffer
.append(" like Java, Spring, Hibernate, String, JSON, Jackson, GSON,");
stringBuffer
.append(" XML parsing, Web Service, SOAP Web Service, RESTful Web Service");

System.out.println("stringBuffer : " + stringBuffer);

}

}


Result


The above code will produce the following output.



plusOperator : Java tutorials corner  contains tutorials for Java programers day to day needs tutorials like Java, Spring, Hibernate, String, JSON, Jackson, GSON, XML parsing, Web Service, SOAP Web Service, RESTful Web Service
stringBuffer : Java tutorials corner  contains tutorials for Java programers day to day needs tutorials like Java, Spring, Hibernate, String, JSON, Jackson, GSON, XML parsing, Web Service, SOAP Web Service, RESTful Web Service

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: String Concatenation in Java Rating: 5 Reviewed By: eHowToNow