
Implement a buffer operation using character array, storing last 100 characters inserted by user. Make method to get and retrieve???

The given code accepts the characters from the user and stored into character array. Then it stores the last 100 character into the StringBuffer and displayed on console.
import java.util.*;
class BufferOperation
{
public static void main(String[] args)
{
StringBuffer buffer=new StringBuffer();
Scanner input=new Scanner(System.in);
char chars[]=new char[150];
for(int i=0;i<chars.length;i++){
System.out.print("Enter character: ");
char ch= input.next().charAt(0);
chars[i]=ch;
}
for(int i=chars.length-100;i<chars.length;i++){
buffer.append(chars[i]);
buffer.append("\n");
}
System.out.println(buffer.toString());
}
}

thanx buddy

this code is not work properly......plz check it and explain me.....plz

kindly put solution of this..given solution is not working
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.