Need help in Queue Implementation

MyQueue
public class MyQueue {
     private int start, end;
     private int[] qArray;
     private int size;
     MyQueue(int size){
          this.size = size;
          qArray = new int[size];
          start = end = -1;
     public int removeFromQueue(){
          int retVal = -1;
          if(isEmpty()){
               System.out.println("Queue is empty");
          }else{
               retVal = qArray[++start];
          return retVal;
     public void addToQueue(int element){
          if((end+1) < size ){
               qArray[++end] = element;
          }else{
               System.out.println("Queue is full. Please flush out someone");
     private boolean isEmpty(){
          return (start==end);
     public String toString(){
          StringBuffer buffer = new StringBuffer();
          for(int i = start; i< end; i++){
               buffer.append(qArray[i]+" ");
          return buffer.toString();
MyQueueImpl
public class MyQueueImpl {
     public static void main(String args[]){
          MyQueue myQueue = new MyQueue(10);
          for(int i = 0; i< 10; i++){
               myQueue.addToQueue((int)(i+ Math.random()));     
          System.out.println(myQueue);
          System.out.println("Removing 3 guys from the queue");
          System.out.println(myQueue.removeFromQueue());
          System.out.println(myQueue.removeFromQueue());
          System.out.println(myQueue.removeFromQueue());
          System.out.println("Adding 10 to the queue");
          myQueue.addToQueue(10);
          System.out.println(myQueue);
          System.out.println();
}

public class MyQueue {
     private int start, end;
     private int[] qArray;
     private int size;
     MyQueue(int size){
          this.size = size;
          qArray = new int[size];
          start = end = -1;
     public int removeFromQueue(){
          int retVal = -1;
          if(isEmpty()){
               System.out.println("Queue is empty");
          }else{
               retVal = qArray[++start];
          return retVal;
     public void addToQueue(int element){
          if((end+1) < size ){
               qArray[++end] = element;
          }else{
               System.out.println("Queue is full. Please flush out someone");
     private boolean isEmpty(){
          return (start==end);
     public String toString(){
          StringBuffer buffer = new StringBuffer();
          for(int i = start; i< end; i++){
               buffer.append(qArray[i]+"   ");
          return buffer.toString();
}public class MyQueueImpl {
     public static void main(String args[]){
          MyQueue myQueue = new MyQueue(10);
          for(int i = 0; i< 10; i++){
               myQueue.addToQueue((int)(i+ Math.random()));     
          System.out.println(myQueue);
          System.out.println("Removing 3 guys from the queue");
          System.out.println(myQueue.removeFromQueue());
          System.out.println(myQueue.removeFromQueue());
          System.out.println(myQueue.removeFromQueue());
          System.out.println("Adding 10 to the queue");
          myQueue.addToQueue(10);
          System.out.println(myQueue);
          System.out.println();

Similar Messages

  • Need help on how implement security.

    Hello everybody,
    I have developed an application with many pages,
    It's time now for me to strat working on the security ....
    I will have the following :
    -Some pages will be accessible by some users but not some others.
    -For some reports, there is a column that will be updatable by some users but nor by others.
    -The users will be grouped into groups.
    I need help on how can I start develop this security model, creating groups perhaps.....
    Thanks for any help.

    Jina,
    Check out Authorization Schemes in the User Guide and under the Security tab in the builder.
    Also search this forum for keywords like "security", "authorization", and "groups"... I think you'll get lots of useful threads.
    Scott

  • Need help on SOA implementation strategies

    I am interested in strategies for implementing SOA using BEA. I figured one would be using WL+ALSB combination, and the other using WL+ALBPM combo (The service is designed in WL). Am I right in my thoughts? Also can anyone please guide me to any article/papers which can compare the two implementations? The points of comparisions that I am interested is ease of orchestrating services, ease of enforcement of SLA & runtime, ease of development and of course SOA Governance issues and the standard NFR's

    I think you're going to need to specify more about the requirements of your project. Try starting with the type of PBX, its interconnections and capacity requirements. You might also put some kind of an upper boundary on your budget since 'cost effective' for one company is certainly not so much for another.

  • Help in Queue Implementation

    Hello All
    I have to implement Queue ... i am able to implement enqueue and dequeue method .. but i am stuck to implement Reading Data from queue and and stroed it in String Array ..
    can any one have idea abt it.. if plz share sample code
    Ashish

    I have to implement Queue ... i am able to implement
    enqueue and dequeue method .. but i am stuck to
    implement Reading Data from queue and and stroed it
    in String Array ..If you are able to implement the dequeue method, how can you be
    stuck on reading data from the queue then? Can you show us some
    (relevant) code (between the proper code tags)?
    kind regards,
    Jos

  • Need help with the implementation of below DLL in LabVIEW Call Lib function

    Here is the list of C functions in the doc that I have but I'm not getting the exact output.
    I need a help only to understand these functions and how to configure it in LabVIEW
    Parameters
    voltType
    [in]Specifies a voltage sensor to get value from. It can be one of the flags
    VCORE (1<<0)
    V25 (1<<1)
    V33 (1<<2)
    V50 (1<<3)
    V120 (1<<4)
    VSB (1<<5)
    VBAT (1<<6)
    VN50 (1<<7)
    VN120 (1<<8)
    VTT (1<<9)
    retval
    [out]Point to a variable in which this function returns the voltage in Volt.
    Typesupport
    [out]
    If the value is specified as a pointer (non-NULL) to a variable, it will return the types of available sensors in flags bitwise-ORed
    Return Value
    TRUE (1) indicates success; FALSE (0) indicates failure.
    Remarks
    Call the function first with a non-NULL typesupport to know the available fan sensors and a following call to get the voltage required.
    =========================================
    Please remember to accept a solutions and show your appreciation by giving Kudos to helpful messages...
    Mangesh D.
    CLAD | Project Engineer
    ==
    VIPM, LabVIEW 8.2, 2009, 2011SP1, 2012, 2012SP1, 2013, cRIO,cDAQ, PXI, ELVIS, Multisim, Smart Camera....
    Solved!
    Go to Solution.

    ManLD wrote:
    Here is the list of C functions in the doc that I have but I'm not getting the exact output.
    I need a help only to understand these functions and how to configure it in LabVIEW
    Parameters
    voltType
    [in]Specifies a voltage sensor to get value from. It can be one of the flags
    VCORE (1<<0)
    V25 (1<<1)
    V33 (1<<2)
    V50 (1<<3)
    V120 (1<<4)
    VSB (1<<5)
    VBAT (1<<6)
    VN50 (1<<7)
    VN120 (1<<8)
    VTT (1<<9)
    retval
    [out]Point to a variable in which this function returns the voltage in Volt.
    Typesupport
    [out]
    If the value is specified as a pointer (non-NULL) to a variable, it will return the types of available sensors in flags bitwise-ORed
    Return Value
    TRUE (1) indicates success; FALSE (0) indicates failure.
    Remarks
    Call the function first with a non-NULL typesupport to know the available fan sensors and a following call to get the voltage required.
    The parameter describtion you show is useless. It tells absolutely nothing about the actual data types used nor how those parameters are exactly supposed to be passed. Show us at least the function prototype too!
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Need help: how to implement sun niagara encryption chip with weblogic

    Hi all, I have a issue with SSL performance on top of T2000 server, thats why I try to use encryption chip provided by SUN T1 technology, but I couldnt find the implementation document for this technology with weblogic server.
    Im using weblogic 9.2MP3 with sun solaris 10. I really appreciate if any body can help me with this problem.
    Thanks,

    Hello,
    How are you obtaining the EntityManager and EntityManagerFactory? If it is injection, you should verify that the second transaction scope gets its own EM/EMF injected rather than being passed the one from the first one.
    Best Regards,
    Chris

  • Need help with queue

    i have this code where I create a BlockingQueue but when I try to compile it gives an error can some one help with this please........
    class consumer implements Runnable{
         private BlockingQueue<int> MilkQueue;
         static int maxConsume=4;
         String name;
         consumer (BlockingQueue<int> q, String name){
              MilkQueue= q;
              name= name;
         }this is my class and my constructoe wollowing is the error that i get
    consumer.java:5: cannot find symbol
    symbol : class BlockingQueue
    location: class consumer
    private BlockingQueue<int> MilkQueue;
    ^
    consumer.java:5: unexpected type
    found : int
    required: reference
    private BlockingQueue<int> MilkQueue;
    ^
    consumer.java:9: cannot find symbol
    symbol : class BlockingQueue
    location: class consumer
    consumer (BlockingQueue<int> q, String name){
    ^
    consumer.java:9: unexpected type
    found : int
    required: reference
    consumer (BlockingQueue<int> q, String name){                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    import java.util.concurrent.*;
    import java.lang.*;
    import java.util.*;
    import java.io.*;
    class consumer implements Runnable{
        public BlockingQueue MilkQueue;
         static int maxConsume=4;
         String name;
         consumer (BlockingQueue q, String name){
              MilkQueue= q;
              name= name;
         public void getMilk(int milkNo){
              System.out.println("consumer "+name+" consumed  milk number : "+milkNo);
              maxConsume--;
         public void run(){
              boolean notempty=MilkQueue.isEmpty();
              try{
                   while(!notempty){
                        getMilk(MilkQueue.take());
                        //sleep(200);
              }catch (InterruptedException e){
                   System.out.println("ERROR : "+e);
              if (maxConsume==0){
                   System.out.println("consumer : " +name+ " is leaving");
                   //destroy();
    }when I compile this code I get the error
    consumer.java:25: getMilk(int) in consumer cannot be applied to (java.lang.Objec
    t)
    getMilk(MilkQueue.take());
    ^
    1 error

  • Need help in operation implementation

    have gone through the CE tutorial page and started building one sample application in CE which will create outbound deliveries in SAP. I am using BAPI_OUTB_DELIVERY_CREATENOREF and BAPI_TRANSACTION_COMMIT to do this job. what i am planning to do here is
    - create CAF project in NWDS 7.11
    - in the external node import these two BAPIs
    - create an application service in modelled node ( with name createobdnsap ).
    -using default mapping option create wrapper operation for the two BAPI'S. when i am doing this i have selected the option "create methods in the existing application service". so that two operations will be created in the application service createobdnsap.
    - now add another operation createdelivery and check the "manually implement"check box.
    - go to .java file of the implementation and call the BAPI_OUTB_DELIVERY_CREATENOREF operation first and then BAPI_TRANSACTION_COMMIT.
    i am stuck up in the last step. i am not able figure out the correct java statement to call the BAPI_OUTB_DELIVERY_CREATENOREF and BAPI_TRANSACTION_COMMIT.
    it would be great if anybody can give me some insight into it.
    thanks

    Did you find the solution?

  • Need help regarding Linked List

    I'm a beginner who just spent ages working on the following code.. but need help on re-implementing the following using a linked list, i.e. no array is allowed for customer records but you still can use arrays for names, address, etc.. Hopefully I've inserted enough comments..
    Help very much appreciated!! Thanks! =]
    import java.util.Scanner;
    import java.io.*;
    public class Bank
    /* Private variables declared so that the data is only accessible to its own
         class, but not to any other class, thus preventing other classes from
         referring to the data directly */
    private static Customer[] customerList = new Customer[30];               
         //Array of 30 objects created for storing information of each customer
    private static int noOfCustomers;                                                       
         //Integer used to store number of customers in customerList
         public static void main(String[] args)
              Scanner sc = new Scanner(System.in);
              menu();
         public static void menu()
              char choice;
              String filename;
              int custId,counter=0;
              double interestRate;
    Scanner sc = new Scanner(System.in);
              do
              //Displaying of Program Menu for user to choose
         System.out.println("ABC Bank Customer Management System Menu");     
         System.out.println("========================================");
         System.out.println("(1) Input Data from File");
         System.out.println("(2) Display Data");
         System.out.println("(3) Output Data to File");
                   System.out.println("(4) Delete Record");
                   System.out.println("(5) Update Record");
         System.out.println("(Q) Quit");
                   System.out.println();
                   System.out.print("Enter your choice: ");
                   String input = sc.next();
                   System.out.println();
                   choice = input.charAt(0);     
              //switch statement used to assign each 'selection' to its 'operation'               
         switch(choice)
         case '1': int noOfRecords;
                                       System.out.print("Enter file name: ");
              sc.nextLine();                                             
              filename = sc.nextLine();
                                       System.out.println();
              noOfRecords = readFile(filename);
    System.out.println(+noOfRecords+" records read.");
              break;
         case '2': displayRecords();
              break;
         case '3': writeFile();
         break;
                        case '4': System.out.print("Enter account ID to be deleted: ");
                                       sc.nextLine();
                                       custId = sc.nextInt();
                                       deleteRecord(custId);
                                       break;
                        case '5': if(counter==0)
              System.out.print("Enter current interest rate for saving account: ");
                                            sc.nextLine();
                                            interestRate = sc.nextDouble();
                                            update(interestRate);
                                            counter++;
                                       else
              System.out.println("Error: Accounts have been updated for the month.");
                                            break;
                   }System.out.println();
         }while(choice!='Q' && choice!='q');
    /* The method readFile() loads the customer list of a Bank from a specified
         text file fileName into customerList to be stored as array of Customer
         objects in customerList in ascending alphabetical order according to the
         customer names */
    public static int readFile(String fileName)
         int custId,i=0;
              String custName,custAddress,custBirthdate,custPhone,custAccType;
              double custBalance,curRate;
              boolean d;
    /* Try block to enclose statements that might throw an exception, followed by
         the catch block to handle the exception */
    try
                   Scanner sc = new Scanner(new File(fileName));
    while(sc.hasNext())          
    /* sc.next() gets rid of "Account", "Id" and "=" */
    sc.next();sc.next();sc.next();
    custId = sc.nextInt();
                        d=checkDuplicate(custId);               
    /* checkDuplicate() is a method created to locate duplicating ids in array */
    if(d==true)
    /* A return value of true indicates duplicating record and the sc.nextLine()
         will get rid of all the following lines to read the next customer's record */
                             sc.nextLine();sc.nextLine();sc.nextLine();
                             sc.nextLine();sc.nextLine();sc.nextLine();
                             continue;     
    /* A return value of false indicates no duplicating record and the following
         lines containing the information of that customer's record is being read
         in */
                        if(d==false)
    /* sc.next() gets rid of "Name" and "=" and name is changed to upper case*/
         sc.next();sc.next();
         custName = sc.nextLine().toUpperCase();
    /* sc.nextLine get rids of the following lines to read the next customer's
         record if length of name is more than 20 characters*/
         if(custName.length()>21)
    System.out.println("Name of custId "+custId+" is more than 20 characters");
                                  System.out.println();
         sc.nextLine();sc.nextLine();sc.nextLine();sc.nextLine();
         continue;
    /* sc.next() gets rid of "Address" and "=" */           
         sc.next();sc.next();
         custAddress = sc.nextLine();
    /* sc.nextLine get rids of the following lines to read the next customer's
         record if length of address is more than 80 characters*/                         
                             if(custAddress.length()>81)
    System.out.println("Address of custId "+custId+" is more than 80 characters");
                                  System.out.println();
         sc.nextLine();sc.nextLine();sc.nextLine();sc.nextLine();
         continue;
    /* sc.next() gets rid of "DOB" and "=" */                              
         sc.next();sc.next();
         custBirthdate = sc.nextLine();
    /* sc.nextLine get rids of the following lines to read the next customer's
         record if length of date of birth is more than 10 characters*/                         
                             if(custBirthdate.length()>11)
    System.out.println("D.O.B of custId "+custId+" is more than 10 characters");
                                  System.out.println();
         sc.nextLine();sc.nextLine();sc.nextLine();sc.nextLine();
         continue;
    /* sc.next() gets rid of "Phone", "Number" and "=" */                              
         sc.next();sc.next();sc.next();
         custPhone = sc.nextLine();
    /* sc.nextLine get rids of the following lines to read the next customer's
         record if length of phone number is more than 8 characters*/                         
                             if(custPhone.length()>9)
    System.out.println("Phone no. of custId "+custId+" is more than 8 characters");
                                  System.out.println();
         sc.nextLine();sc.nextLine();sc.nextLine();sc.nextLine();
         continue;
    /* sc.next() gets rid of "Account", "Balance" and "=" */                              
         sc.next();sc.next();sc.next();
         custBalance = sc.nextDouble();
    /* sc.next() gets rid of "Account", "Type" and "=" */                              
                             sc.next();sc.next();sc.next();
                             custAccType = sc.next();
                             if(custAccType.equals("Saving"))
    customerList[noOfCustomers] = new Account1(custId,custName,custAddress,custBirthdate,custPhone,custBalance,custAccType);
    sc.nextLine();
                                                 noOfCustomers++;
                                                 i++;
    else if(custAccType.equals("Checking"))
    customerList[noOfCustomers] = new Account2(custId,custName,custAddress,custBirthdate,custPhone,custBalance,custAccType);
                                                 sc.nextLine();
                                                 noOfCustomers++;
                                                 i++;
    else if(custAccType.equals("Fixed"))
    sc.next();sc.next();sc.next();sc.next();
                                                 curRate = sc.nextDouble();
                                                 Account3 temp = new Account3(custId,custName,custAddress,custBirthdate,custPhone,custBalance,custAccType,curRate);
                                                 customerList[noOfCustomers]=temp;
                                                 sc.nextLine();
                                                 noOfCustomers++;
                                                 i++;
                             else
                                  System.out.println("Account type not defined.");
         if(noOfCustomers==30)
         System.out.println("The customer list has reached its maximum limit of 30 records!");
         System.out.println();
         return noOfCustomers;
    //Exceptions to be caught
    catch (FileNotFoundException e)
    System.out.println("Error opening file");
    System.exit(0);
    catch (IOException e)
    System.out.println("IO error!");
    System.exit(0);
    /* Bubblesort method used to sort the array in ascending alphabetical order
         according to customer's name */
    bubbleSort(customerList);
              return i;
    /* The method displayRecords() displays the data of the customer records on
         screen */
    public static void displayRecords()
    int k;
    /* Displaying text using the printf() method */
         for(k=0;k<noOfCustomers;k++)
         System.out.printf("Name = %s\n", customerList[k].getName());
         System.out.printf("Account Balance = %.2f\n", customerList[k].getBalance());
         System.out.printf("Account Id = %d\n", customerList[k].getId());
    System.out.printf("Address = %s\n", customerList[k].getAddress());
    System.out.printf("DOB = %s\n", customerList[k].getBirthdate());
    System.out.printf("Phone Number = %s\n", customerList[k].getPhone());
         String type = customerList[k].getAccType();
         System.out.println("Account Type = " +type);
    if(type.equals("Fixed"))
         System.out.println("Fixed daily interest = "+((Account3)customerList[k]).getFixed());
         System.out.println();               
    /* The method writeFile() saves the content from customerList into a
         specified text file. Data is printed on the screen at the same time */
    public static void writeFile()
    /* Try block to enclose statements that might throw an exception, followed by
    the catch block to handle the exception */
    try
    int i;
              int n=0;
    //PrintWriter class used to write contents of studentList to specified file
              FileWriter fwStream = new FileWriter("newCustomers.txt");
              BufferedWriter bwStream = new BufferedWriter(fwStream);
              PrintWriter pwStream = new PrintWriter(bwStream);     
    for(i=0;i<noOfCustomers;i++)
         pwStream.println("Account Id = "+customerList.getId());
              pwStream.println("Name = "+customerList[i].getName());
    pwStream.println("Address = "+customerList[i].getAddress());
    pwStream.println("DOB = "+customerList[i].getBirthdate());
    pwStream.println("Phone Number = "+customerList[i].getPhone());
              pwStream.printf("Account Balance = %.2f\n", customerList[i].getBalance());
              pwStream.println("Account Type = "+customerList[i].getAccType());
                   if(customerList[i].getAccType().equals("Fixed"))
                        pwStream.println("Fixed Daily Interest = "+((Account3)customerList[i]).getFixed());
              pwStream.println();
              n++;
    //Closure of stream
    pwStream.close();
              System.out.println(+n+" records written.");
    catch(IOException e)
    System.out.println("IO error!");     
    System.exit(0);
         //Deletes specified record from list
    public static void deleteRecord(int id)
    int i;
              i=locate(id);
    if(i==200)
    //checking if account to be deleted does not exist
    System.out.println("Error: no account with the id of "+id+" found!");
              //if account exists
    else
                        while(i<noOfCustomers)
                             customerList[i] = customerList[i+1];
                             i++;
                        System.out.println("Account Id: "+id+" has been deleted");
                        --noOfCustomers;
         //Updates the accounts
    public static void update(double interest)
    int i,j,k;
              double custBalance,addition=0;
    for(i=0;i<noOfCustomers;i++)
                        if(customerList[i] instanceof Account1)
                             for(j=0;j<30;j++)
                                  addition=customerList[i].getBalance()*interest;
                                  custBalance=customerList[i].getBalance()+addition;
                                  customerList[i].setBalance(custBalance);
                        else if(customerList[i] instanceof Account2)
                             continue;
                        else if(customerList[i] instanceof Account3)
                             for(j=0;j<30;j++)
    addition=customerList[i].getBalance()*((Account3)customerList[i]).getFixed();
    custBalance=customerList[i].getBalance()+addition;
    customerList[i].setBalance(custBalance);
                        else
                             System.out.println("Account type not defined");
              System.out.println("The updated balances are: \n");
              for(k=0;k<noOfCustomers;k++)
    System.out.printf("Name = %s\n", customerList[k].getName());
    System.out.printf("Account Balance = %.2f\n", customerList[k].getBalance());
    System.out.println();
    /* ================== Additional methods ==================== */     
    /* Bubblesort method to sort the customerList in ascending alphabetical
         order according to customer's name */
    public static void bubbleSort(Customer[] x)
    int pass, index;
    Customer tempValue;      
    for(pass=0; pass<noOfCustomers-1; pass++)          
    for(index=0; index<noOfCustomers-1; index++)
    if(customerList[index].getName().compareToIgnoreCase(customerList[index+1].getName()) > 0)
    tempValue = x[index];
    x[index] = x[index+1];
    x[index+1]= tempValue;
    /* Method used to check for duplicated ids in array */     
         public static boolean checkDuplicate(int id)
              int i;
              for(i=0;i<noOfCustomers;i++)
                   if(id == customerList[i].getId())
    System.out.println("Account Id = "+id+" already exists");
                        System.out.println();
    return true;
              }return false;
    /* Method to seach for account id in array */
         public static int locate(int id)
              int j;
              for(j=0;j<noOfCustomers;j++)
                   if(customerList[j].getId()==id)
                        return j;
              j=200;
              return j;
    import java.util.Scanner;
    public class Customer
    /* The following private variables are declared so that the data is only
         accessible to its own class,but not to any other class, thus preventing
         other classes from referring to the data directly */
         protected int id;               
         protected String name,address,birthdate,phone,accType;                              
         protected double balance;               
    // Null constructor of Customer
         public Customer()
              id = 0;
              name = null;
              address = null;
              birthdate = null;
              phone = null;
              balance = 0;
              accType = null;
    /* The following statements with the keyword this activates the Customer
         (int id, String name String address, String birthdate, String phone, double
         balance) constructor that has six parameters of account id, name, address,
         date of birth, phone number, account balance and assign the values of the
         parameters to the instance variables of the object */     
         public Customer(int id, String name, String address, String birthdate, String phone, double balance, String accType)
    //this is the object reference that stores the receiver object     
              this.id = id;
              this.name = name;                         
              this.address = address;
              this.birthdate = birthdate;
              this.phone = phone;
              this.balance = balance;
              this.accType = accType;
    /* The following get methods getId(), getName(), getAddress(), getBirthdate(),
         getPhone(), getBalance() return the values of the corresponding instance
         properties */     
         public int getId()
              return id;
         public String getName()
              return name;
         public String getAddress()
              return address;
         public String getBirthdate()
              return birthdate;
         public String getPhone()
              return phone;
         public double getBalance()
              return balance;
         public String getAccType()
              return accType;
    /* The following set methods setId(), setName(), setAddress(), setBirthdate(),
         setPhone and setBalance() set the values of the corresponding instance
         properties */
         public void setId (int custId)
              id = custId;
         public void setName(String custName)
              name = custName;
         public void setAddress (String custAddress)
              address = custAddress;
         public void setBirthdate (String custBirthdate)
              birthdate = custBirthdate;
         public void setPhone (String custPhone)
              phone = custPhone;
         public void setBalance (double custBalance)
              balance = custBalance;
         public void setAccType (String custAccType)
              accType = custAccType;
    class Account1 extends Customer
         public Account1(int id, String name, String address, String birthdate, String phone, double balance, String accType)
              super(id,name,address,birthdate,phone,balance,accType);
              this.id = id;
              this.name = name;                         
              this.address = address;
              this.birthdate = birthdate;
              this.phone = phone;
              this.balance = balance;
              this.accType = accType;
    class Account2 extends Customer
         public Account2(int id, String name, String address, String birthdate, String phone, double balance, String accType)
              super(id,name,address,birthdate,phone,balance,accType);
              this.id = id;
              this.name = name;                         
              this.address = address;
              this.birthdate = birthdate;
              this.phone = phone;
              this.balance = balance;
              this.accType = accType;
    class Account3 extends Customer
         protected double fixed=0;
         public Account3(int id, String name, String address, String birthdate, String phone, double balance, String accType, double fixed)
              super(id,name,address,birthdate,phone,balance,accType);
              this.id = id;
              this.name = name;                         
              this.address = address;
              this.birthdate = birthdate;
              this.phone = phone;
              this.balance = balance;
              this.accType = accType;
              this.fixed = fixed;
         public double getFixed()
              return fixed;
    Example of a customers.txt
    Account Id = 123
    Name = Matt Damon
    Address = 465 Ripley Boulevard, Oscar Mansion, Singapore 7666322
    DOB = 10-10-1970
    Phone Number = 790-3233
    Account Balance = 405600.00
    Account Type = Fixed
    Fixed Daily Interest = 0.05
    Account Id = 126
    Name = Ben Affleck
    Address = 200 Hunting Street, Singapore 784563
    DOB = 25-10-1968
    Phone Number = 432-4579
    Account Balance = 530045.00
    Account Type = Saving
    Account Id = 65
    Name = Salma Hayek
    Address = 45 Mexican Boulevard, Hotel California, Singapore 467822
    DOB = 06-04-73
    Phone Number = 790-0000
    Account Balance = 2345.00
    Account Type = Checking
    Account Id = 78
    Name = Phua Chu Kang
    Address = 50 PCK Avenue, Singapore 639798
    DOB = 11-08-64
    Phone Number = 345-6780
    Account Balance = 0.00
    Account Type = Checking
    Account Id = 234
    Name = Zoe Tay
    Address = 100 Blue Eyed St, Singapore 456872
    DOB = 15-02-68
    Phone Number = 456-1234
    Account Balance = 600.00
    Account Type = Saving

    1) When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read.
    2) Don't just post a huge pile of code and ask, "How do I make this work?" Ask a specific question, and post just enough code to demonstrate the problem you're having.
    3) Don't just write a huge pile of code and then test it. Write a tiny piece, test it. Then write the piece that will work with or use the first piece. Test that by itself--without the first piece. Then put the two together and test that. Only move on to the next step after the current step produces the correct results. Continue this process until you have a complete, working program.

  • Need Help In Solving Writing To Queue Problem

    Hi Guys,
    I have two threads that are adding to the same message queue. The first one is suppose to add four integers consecutively. Meanwhile the second thread add an integer in between the four integers. Because of that my application is not working properly. I would like that when a thread is adding then the other must wait before it adds. The method that the threads call to add to the queue are all synchronized, but it is still behaving like that.
    I need help in solving it.
    Thanks.
    Edited by: kap on Aug 9, 2010 5:22 AM

    kap wrote:
    Please what do you mean by synchronizing on the same object? Can you explain it to me?
    When you synchronize a block of Java code, you synchronize on a particular object, which is called the Monitor.
    The effect is only to prevent another thread running this, or another block of code synchronized on the same object.
    If you use synchronized methods, then the monitor is the object to which the method belongs (or the class if the method is static). The same synchronized method can be executed simultaneously on a different instance of the object.

  • Need help on Multi level menu implementation

    Hi All,
    Need help on Multi level menu implementation
    Thanks,
    Anu

    Hi Anu,
    Please go through this link Implement Multilevelmenu navigation
    Thanks,

  • I need help with a textArea which wont implement a JScrollpane

    I have created a text area, but when the words get to the bottom there is no scrollbar. I tried implementing the scrollpane to the text area, but it doesnt work. I added it to a panel, then the panel to the frame.
    (Here are the snippits of coding that I have)
    public class RPS extends JFrame implements ActionListener, ItemListener
    JTextArea textDisplay = new JTextArea(50,30);
    JScrollPane jscrollpane = new JScrollPane(textDisplay);
    //constructor?
    public RPS()
    ///various menu items in here and buttons with action listeners
    public void createPanel()
         JPanel outputPanel = new JPanel();
                outputPanel.setLayout(new GridLayout(1,1));
                outputPanel.setBorder(BorderFactory.createTitledBorder("TEXT IN HERE"));
                outputPanel.add(textDisplay);
    //further down
              JPanel rightPanel = new JPanel(new GridLayout(3,1));
              JPanel leftPanel = new JPanel(new GridLayout(1,1));
         leftPanel.add(outputPanel);
              add(leftPanel);
              add(rightPanel);
         public static void main(String[] args)
              JFrame frame = new RPS();
              frame.setLayout(new GridLayout(1,2));
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
    }So what I have is a frame, with two panels. One on the left and one on the right. The textDisplay (text area) is displayed on the outputPanel, which is then added to the left panel, then added to the frame. The right panel is for all the buttons which I left out to keep this simple.
    Can anyone help me please? All the other irrelevant coding has been left out.
    Need help asap please :( I was sure everything is correct.

    you add the textArea to the scrollPane
    JScrollPane jscrollpane = new JScrollPane(textDisplay);but then you add (only) the textArea to the panel
    outputPanel.add(textDisplay);whereas you should be adding the scrollpane to the panel
    outputPanel.add(jscrollpane);

  • Help needed on Logging Servlet Implementation using high traffic HTTP Post

    I have a servlet called LogServlet, which accepts the post HTTP request Data from another application and logs it into a file. The key thing here is the logs should get logged in a squence it is received.
    Since the frequency of the data being sent is very high the LogServlet is not able to keep it up with the sequence and messing up the sequence.
    Are there any suggestions on how to improve this and make sure the servlet logs it in the way it receives it?
    Can I replace the Servlet with JSP to do the logging and will that solve my sequence issue?
    Or there are any other techniques.
    Thanking you in advance.

    You could use the log4j logging tool, it uses a static Logger for the class and you can run it in synchronized mode to ensure that your log messages don't clobber each other. Hmm, you're testing my knowledge of how synchronization is implemented in Java. It uses a semaphore-style approach under the covers, but is it a fair-style (first-come, first-served) implementation?
    After a quick Google search I just learned that in the normal VM fairness is not guaranteed, but if you use the Sun Real-Time VM synchronized will guarantee FIFO style access to synchronized resources. The Real-Time VM is not free, so if cost is an issue that might not be an option for you. That's going to make things more complicated for you since ordering sounds important.
    You can probably write something fairly easily to do what you want. Basically write a queue processing class that uses either static methods/variables or a Singleton approach to ensure that your messages get processed in a FIFO order. Then just use your existing logging logic or use log4j to write your messages to a log file. There are several pitfalls to writing multi-threaded components like this, so be careful that you've synchronized the right methods and, depending on how you decide to implement it, use the right Queue implementation (hint: you may need to look in the java.util.concurrent package for your queue implementation, depending on the approach you take.)
    One thing to note, this last approach may be overkill depending on what you mean by "very high frequency." If you're getting 10-20 requests a second, I think you still might be able to get away with log4j in synchronized mode. It also depends on how important the ordering really is. If one request arrives 500 microseconds after the other, is it okay to reverse the ordering? If so then syncrhonized log4j may still be okay. If not, then you're going to have to write something a little more sophisticated or take a closer look at the capabilities of the real-time VM.
    Alternatively, someone who's more knowledgeable than me on the subject might be able to suggest a better approach using JMS.

  • Need help with Business One Implementation Consultant Certification

    Hello,
    I need help preparing for the B1 certification. I have taken the test once already and failed. I found it very tricky with multiple correct answers for each question.
    I have gone thru the eLearning several times now. And this week I am taking the instructor led training. I have also purchased and studied the Ebook. I have a good grasp of the product, but I feel that this is not enough to help prepare for the test.
    I want to know if there are any other resources I could use to help prepare for the test. Are there any practice exams
    Any and all help is appreciated
    Thank you!
    John
    jseftonATsophlogic.com

    Hi John,
    I found the e-learning good , but a bit limited, so I branched out to these & passed quite well :
    - documentation links on the 2007 landing page:
    Channel Partner Portal -> Solutions -> SAP Business One -> Hot Topics -> 2007
    - ETS:
    Channel Partner Portal -> Solutions -> SAP Business One -> Support -> Training & Knowledge
    - DRC:
    Channel Partner Portal -> Solutions -> SAP Business One -> Support -> Documentation resource centre
    Hope it helps & good luck!
    All the best,
    kerstin

  • Implementing web service Client? need help

    hi,
    i need to develop a funciton in java that takes WSDL address as a input. and using the web service address, start the web service programmatically from that function. the web service could be any.
    i need help and suggestion what to do in the area, how can i start this, as i am a new bie.
    thanks
    Farurkh

    I got the following error.
    But If I call it from a jsp page or a servlet. Nothing happend, Transaction is successful.
    java.lang.NullPointerException
         at org.apache.commons.discovery.resource.ClassLoaders.getAppLoaders(ClassLoaders.java:206)
         at org.apache.axis.AxisProperties.getClassLoaders(AxisProperties.java:118)
         at org.apache.axis.AxisProperties.getNameDiscoverer(AxisProperties.java:105)
         at org.apache.axis.AxisProperties.getResourceClassIterator(AxisProperties.java:112)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder$1.run(EngineConfigurationFactoryFinder.java:116)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:113)
         at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:160)
         at org.apache.axis.client.Service.getEngineConfiguration(Service.java:813)
         at org.apache.axis.client.Service.getAxisClient(Service.java:104)
         at org.apache.axis.client.Service.<init>(Service.java:113)
         at org.tempuri.wsdl.EFSnet2Locator.<init>(EFSnet2Locator.java:10)
         at com.ipharmacy.payment.Payment.main(Payment.java:12)

Maybe you are looking for