CharSequence java - What is CharSequence in java code example
public class Test {
public static void main(String[] args) {
StringBuffer stringBuffer = new StringBuffer ("Hello World");
CharSequence charSequence = stringBuffer;
// print charSequence
System.out.println(charSequence);
// Append first in StringBuffer
stringBuffer.append(" First Append");
System.out.println(charSequence);
// Append sceond in StringBuffer
stringBuffer = stringBuffer.append(" Second Append");
System.out.println(charSequence);
//Append third in StringBuffer
stringBuffer.setLength(0);
stringBuffer = stringBuffer.append(" Third Append");
System.out.println(charSequence);
}
}
public static void main(String[] args) {
StringBuffer stringBuffer = new StringBuffer ("Hello World");
CharSequence charSequence = stringBuffer;
// print charSequence
System.out.println(charSequence);
// Append first in StringBuffer
stringBuffer.append(" First Append");
System.out.println(charSequence);
// Append sceond in StringBuffer
stringBuffer = stringBuffer.append(" Second Append");
System.out.println(charSequence);
//Append third in StringBuffer
stringBuffer.setLength(0);
stringBuffer = stringBuffer.append(" Third Append");
System.out.println(charSequence);
}
}
Comments
Post a Comment