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);
        }
}

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

How to capture finger prints in java

Shallow Copy Deep Copy Java example