Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java code for buffer operation...!!!
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Pankaj Jain
Java code for buffer operation...!!!
4 Answer(s)      2 years and 6 months ago
Posted in : Java Beginners


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


Advertisement
View Answers

June 18, 2012 at 5:24 PM


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


June 18, 2012 at 5:30 PM


thanx buddy



June 18, 2012 at 6:17 PM


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



April 15, 2013 at 12:46 PM


kindly put solution of this..given solution is not working



Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com