Search This Blog

save java programs with".java" extension

examples :

helloworld.java
sample.java
match.java
send-mail.java

quick links

string append


class stringtest {

public static void main(String[] args) {

String s= new String("hello "); // immutable string created.
String str= s.concat("how are you");
System.out.println(s);
System.out.println(str);

StringBuffer sb= new StringBuffer("hello"); //mutable string created.
sb.append("how are you");
System.out.println(sb);

StringBuilder sbuilder= new StringBuilder("hello"); //mutable string created
sbuilder.append("how are you");
System.out.println(sbuilder);
}

}