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
0 comments:
Post a Comment