Stack Class

Hello.
I'm trying to implement a stack class, where the stack only holds boolean values, and will have a maximum size of about 32.
I've designed an interface which looks like:
public interface IBooleanStack {
    public void push(Boolean b);
    public Boolean pop();
    public Boolean top();
    public boolean isEmpty();
    public void clear();
    public int size();
}What would you suggest would be the best way to implement this? Should I use an array, or the built-in stack?
The reason I ask is that if I were to use the built-in stack implementation, would that not make my push() and pop() methods redundant? I have to use them, which is why I was considering other options.
Thanks :)
Edited by: chrisdb89 on Oct 29, 2008 4:09 AM

Thank you all for your advice.
I got the arrayStack to work, so that's good.
I also implemented an sllStack, basically the same way, however when I pop anything from the stack, it always returns null.
I'm importing the following:
package uk.ac.stand.cs.cs2001.Prac05.sll;
public class SLLNode {
     public Boolean b;
     public SLLNode next;
     public SLLNode (Object element, SLLNode next) {
     this.b = b;
     this.next = next;
}and here is my implementation of the SLL:
package uk.ac.stand.cs.cs2001.Prac05.impl;
import uk.ac.stand.cs.cs2001.Prac05.interfaces.IBooleanStack;
import uk.ac.stand.cs.cs2001.Prac05.sll.SLLNode;
public class SLLStack implements IBooleanStack {
     private SLLNode root;
     private int current_size;
     public SLLStack() {
          root = null;
          current_size = 0;
     public void push(Boolean b) {
          root = new SLLNode(b, root);
          current_size++;
     public Boolean pop() {
          if (!isEmpty()) {
               Boolean b = root.b;
               root = root.next;
               current_size--;
               return b;
          } else {
               throw new IllegalStateException("Error: Stack is full.");
     public Boolean top() {
          if (!isEmpty()) {
               return root.b;
          } else {
               throw new IllegalStateException("Error: Stack is full.");
     public int size() {
          return current_size;
     public boolean isEmpty() {
          return root == null;
     public void clear() {
          root = null;
          current_size = 0;
     public static void main(String[] args) {
          IBooleanStack sllStack = new SLLStack();
          sllStack.push(true);
          System.out.println("'True' added to stack.\n");
          sllStack.push(false);
          System.out.println("'False' added to stack.\n");
          while (!sllStack.isEmpty()) {
               System.out.println(sllStack.pop());
}Can anybody tell me what I'm missing? Any help will be greatly appreciated.
We haven't covered DLL in class, so I don't think I should use that implementation for this :)
Thanks again.
Chris

Similar Messages

  • Modifying the stack class to use multiple threads

    Im trying to re write the stack class but with using 2 threads. One of the thread calls the pop method and the other calls the push method.
    I don't know where im going wrong...
    Any tips would be great thnx
    Haven't bothered putting in any try / catch clauses yet, will make it look pretty later :)
    http://nopaste.php-q.net/19555

    java.util.Stack is thread safe so all you need to do are create two threads
    one which pushes data onto the stack and one which pops it off.
    class PushThread implements Runnable {
       private Stack stack;
       public PushThread(Stack s) {
          this.stack = s;
       public void run() {
         while(true) { // loop for ever
            stack.push(new Object());
            for(int i=0;i<100000;i++); // waste some time.
    }The code above deliberatly does not use wait, sleep, notify etc as these
    would force an ordering onto the stack. The code instead goes into a
    loop that should waste time.
    your PopThread class will be identical but will call stack.pop() instead.
    matfud

  • Confusion about size and capacity of Stack class

    import java.util.*;
    public class StackDemo {
         static void s_pop(Stack<Integer> s)
              System.out.print("Pop elements of Stack: ");
              try
                   for(int i=0;i<s.size();i++)
                        System.out.print(s.pop()+" ");
              }catch(EmptyStackException e)
                   System.out.println("Empty Stack");
         public static void main(String[] args) {
              Stack<Integer> s=new Stack<Integer>();
              System.out.println("Size of Stack s: "+s.size());
              System.out.println("Capacity of Stack s: "+s.capacity());
              s.push(10);
              s.push(29);
              s.push(76);
              s.push(-7);
              System.out.println("Now the size of Stack s: "+s.size());
              System.out.println("Now the capacity of Stack s: "+s.capacity());
              System.out.print("Elements of Stack: ");
              for(int i:s)
                   System.out.print(i+" ");
              System.out.println();
              s.push(32);
              s.push(46);
              System.out.println("Now the Size of Stack s: "+s.size());
              System.out.println("Now the capacity of Stack s: "+s.capacity());
              System.out.print("Elements of Stack: ");
              for(int i:s)
                   System.out.print(i+" ");
              System.out.println();
              s_pop(s);
    } The outputs:
    Size of Stack s: 0
    Capacity of Stack s: 10
    Now the size of Stack s: 4
    Now the capacity of Stack s: 10
    Elements of Stack: 10 29 76 -7
    Now the Size of Stack s: 6
    Now the capacity of Stack s: 10
    Elements of Stack: 10 29 76 -7 32 46
    Pop elements of Stack: 46 32 -7 // where are the other elements of Stack
    import java.util.*;
    public class StackDemo {
         static void s_pop(Stack<Integer> s)
              System.out.print("Pop elements of Stack: ");
              try
                   for(int i=0;i<s.capacity();i++)
                        System.out.print(s.pop()+" ");
              }catch(EmptyStackException e)
                   System.out.println("Empty Stack");
         public static void main(String[] args) {
              Stack<Integer> s=new Stack<Integer>();
              System.out.println("Size of Stack s: "+s.size());
              System.out.println("Capacity of Stack s: "+s.capacity());
              s.push(10);
              s.push(29);
              s.push(76);
              s.push(-7);
              System.out.println("Now the size of Stack s: "+s.size());
              System.out.println("Now the capacity of Stack s: "+s.capacity());
              System.out.print("Elements of Stack: ");
              for(int i:s)
                   System.out.print(i+" ");
              System.out.println();
              s.push(32);
              s.push(46);
              System.out.println("Now the Size of Stack s: "+s.size());
              System.out.println("Now the capacity of Stack s: "+s.capacity());
              System.out.print("Elements of Stack: ");
              for(int i:s)
                   System.out.print(i+" ");
              System.out.println();
              s_pop(s);
    The outputs:
    Size of Stack s: 0
    Capacity of Stack s: 10
    Now the size of Stack s: 4
    Now the capacity of Stack s: 10
    Elements of Stack: 10 29 76 -7
    Now the Size of Stack s: 6
    Now the capacity of Stack s: 10
    Elements of Stack: 10 29 76 -7 32 46
    Pop elements of Stack: 46 32 -7 76 29 10 Empty Stack
    When i use s.size() in the first program then only first 3 elements are poped.But when i use s.capacity() in the second program then all of the elements are poped.But the size of the stack is 6 in both program.Then why all of the elements are not poped when I use size method of Stack????

    > for(int i=0;i<s.size();i++)
         System.out.print(s.pop()+" ");
    }Realize that s.size() is computed everytime the loop body is entered.
    That size changes after the loop body (the 'pop') has been executed.
    Better do this:for (int i= 0, n= s.size(); i < n; i++)
       System.out.print(s.pop()+" ");kind regards,
    Jos

  • Stack class help

    hi i was wondering if anyone could help me, i keep getting 2 errors on the pop and push methods sayin it cannot find the variable.
    package labwork1;
    import java.util.*;
    * @author me
    public class Main
        public Main() {
        public static void main(String[] args)
          Stack stk = new Stack();
        public void help(String object)
            if(object.startsWith("-")){
                stk.pop();
            else{
                   stk.push(object);
    }

    ok i get that the scope of the stack is only in the
    main method, how would i solve this, so that the push
    and pop methods will work?Not sure what you are doing but:
    Declare it in the class as an instance variable.

  • Stack Class and IF loops

    Fellow programmers,
    I would appreciate a bit of help here. First of all, does a Stack start at index zero?
    Secondly, i am popping an Object off the stack, s.pop() and storing it as 'object'.
    Then my aim is to search the remainder of the stack to see if there is an identical Object still in the stack.
    Note that each Object in the stack is a 'transObject' possessing one of either two forms. Either 1) "trans type" where type is "COMMITS"
    or 2) "trans type resource"
    Upon finding a matching Object still in the stack, inStack is set to true.
    I have provided my code so far, containing some nasty if-else loops, for which i do apologise.
    Please please give me some super guidance.
    Thank you for your time and efforts!
    SEE CODE BELOW (feel free to modify):
    if (event.getSource() == button_previous) {
         if (index >= 0) {
              index = index - 1;
              list.ensureIndexIsVisible(index);
              list.setSelectedIndex(index);
              object = s.pop();
              boolean inStack = false;
              type = ((transObject) object).getType();
              if (type.equals("COMMITS")) {
                   trans = ((transObject) object).getTransaction();
              } else {
                   trans = ((transObject) object).getTransaction();
                   resource = ((transObject) object).getResource();
              for (int i=0; i<s.size(); i++) {
                   object_test = s.get(i);
                   type_test = ((transObject) object_test).getType();
                   if (type_test.equals("COMMITS")) {
                        trans_test = ((transObject) object_test).getTransaction();
                        System.out.println("type_test: " + type_test);
                        System.out.println("trans_test: " + trans_test);
                   } else {
                        trans_test = ((transObject) object_test).getTransaction();
                        res_test = ((transObject) object_test).getResource();
                        System.out.println("type_test: " + type_test);
                        System.out.println("trans_test: " + trans_test);
                        System.out.println("res_test: " + res_test);
                   if (type_test.equals("COMMITS")) {
                        System.out.println("first if to test if COMMITS type_test: " + type_test);
                        if (type_test == type) {
                             System.out.println("second if type_test: " + type_test);
                             if (trans_test == trans) {
                                  System.out.println("third if trans_test, and inStack set to TRUE: " + trans_test);
                                  inStack = true;
                   } else {
                        if (type_test == type) {
                             System.out.println("first if type_test: " + type_test);
                             if (trans_test == trans) {
                                  System.out.println("second if trans_test: " + trans_test);
                                  if (res_test == resource) {
                                       System.out.println("third if res_test, and inStack set to TRUE: " + res_test);
                                       inStack = true;
              } // end for

    You are using the wrong data structure for your objective. Stacks are for LIFO (Last In First Out) and Queues are for (First In First Out). There is no searching or comparing of objects in either of these structures, simply push/pop, Enqueue/Dequeue, isFull() and isEmpty().
    You may want to create your own Array or LinkedList class.

  • How to access a Stack class from different classes

    Hi
    I have a Stack implemented as Stack.java. I have 2 more java files Control.java and display.java.
    In Control.java
    I have created Stack stack = new Stack(); and am pushing values in the stack.
    In display.java i have some conditions where i want to push some values in the same stack as that on the Control.java.
    How do i acces the stack in Control.java from other files like display.java

    In display.java i have some conditions where i want
    to push some values in the same stack as that on the
    Control.java.
    How do i acces the stack in Control.java from other
    files like display.javaPass that object reference to some method. :-)

  • Stack Size

    For an assignment I had to create a postfix calculator, and one of the errors we had to catch was:
    if there is more then one integer left in the stack when printing the final result, it needs
    to give an error message and exit.
    We were provided the implementation and interface for the Stack by our instructor and here is the method he used for toString.
        public String toString() {
         if (empty()) {
             return "Empty Stack";
         } else {
             return recursiveToString(top);
        /* recursive method to print a non-empty stack
         * @param     the starting index in the array
         * @return     a string representing the stack
        private String recursiveToString(IntNode start) {
         if (start == null) {
             return "";
         String separator = "";
         if (start != top) {
             separator = " :: ";
         return recursiveToString(start.getNext()) +
                    start.getValue() + separator;
        }Basically if there is more than one integer in the stack it will print it like so:
    1 :: 2 :: 3 :: 4
    This is what I used to tell if there was more than one integer left in the stack when printing the final results. I used this code:
    //Checking for the "::" that the toString method prints between integers
    //when there is more than one left in the stack. If there is more the one
    //integer left in the stack then give an error and exit.
    for(int i = 0; i < intStack.toString().length(); i++) { //looping through the toString
    //if there are two colons, consecutively, there is more than one integer in the stack
         if(intStack.toString().charAt(i) == ':' && intStack.toString().charAt(i+1) == ':') {
              System.out.println("Error:\tMore than one integer in final stack. Make sure equations\n\tin " + param[0] + " are valid. Exiting program...");
              System.exit(1);
    }Now my question is... is there a better way to do this? Ideally I would like this part to work regardless
    of how the toString method formats the integers. Because right now if the toString method was
    changed my little check would not work. So is there a way to determine the amount of items in a stack
    or a better way to do this.
    To give a better understanding of those snippets here is the code as a whole:
    import java.util.EmptyStackException;
    import java.util.Scanner;
    import java.io.File;
    public class KinseyAnthony4 {
         public static void main(String[] param) {
              /** Declare new IntLinkedStack Stack Object */
              IntLinkedStack intStack = new IntLinkedStack();
              //Make sure there is only one parameter entered.
              if(param.length == 1) {
                   //try to read the file
                   try {
                        /** declaring new file object */
                        File calcMe = new File(param[0]);
                        /** declaring new scanner object */
                        Scanner readIt = new Scanner(calcMe);
                        /** declaring int for line number */
                        int line = 1;
                        /** declaring int for first number popped from stack */
                        int top = 0;
                        /** declaring int for second number popped from stack */
                        int next = 0;
                        /** declaring int to hold the result of calculations */
                        int result = 0;
                        //Report current status
                        System.out.println("Reading through " + param[0] + ":");
                        //Use loop to view each line until there are none left
                        while(readIt.hasNextLine()) {
                            /** declaring string that holds current line's content */
                             String lineContent = readIt.nextLine();
                             //Report current line number and it's contents
                             System.out.println("\nLine " + line + ": " + lineContent);
                             //Use for loop to analyze each character in the line
                             for(int i=0; i < lineContent.length(); i++) {
                                  //Is it a digit?
                                  if(Character.isDigit(lineContent.charAt(i))) {
                                       /** declaring int that holds numeric value of the char */
                                       int pushMe = Character.getNumericValue(lineContent.charAt(i));
                                       //Report what's being pushed on stack
                                       System.out.println(">Pushing " + pushMe + " to stack.");
                                       //Push the value on the stack
                                       intStack.push(pushMe);
                                  //It's not a digit
                                  else {
                                       //Use a switch statement for computations
                                       switch(lineContent.charAt(i)) {
                                            //Multiplication
                                            case '*':
                                                 top = intStack.pop(); //Pop top number
                                                 System.out.println(">Popping " + top + " from stack."); //Status
                                                 next = intStack.pop(); //Pop next number
                                                 System.out.println(">Popping " + next + " from stack."); //Status
                                                 result = next * top; //Multiply them
                                                 System.out.println(">Calculating " + next + " * " + top); //Status
                                                 intStack.push(result); //Push result back onto stack
                                                 System.out.println(">Pushing result of " + result + " to stack."); //Status
                                                 break;
                                            //Division
                                            case '/':
                                                 top = intStack.pop(); //Pop top number
                                                 System.out.println(">Popping " + top + " from stack."); //Status
                                                 next = intStack.pop(); //Pop next number
                                                 System.out.println(">Popping " + next + " from stack."); //Status
                                                 result = next / top; //Divide them
                                                 System.out.println(">Calculating " + next + " / " + top); //Status
                                                 intStack.push(result); //Push result back onto stack
                                                 System.out.println(">Pushing result of " + result + " to stack."); //Status
                                                 break;
                                           //Addition
                                            case '+':
                                                 top = intStack.pop(); //Pop top number
                                                 System.out.println(">Popping " + top + " from stack."); //Status
                                                 next = intStack.pop(); //Pop next number
                                                 System.out.println(">Popping " + next + " from stack."); //Status
                                                 result = next + top; //Add them
                                                 System.out.println(">Calculating " + next + " + " + top); //Status
                                                 intStack.push(result); //Push result back onto stack
                                                 System.out.println(">Pushing result of " + result + " to stack."); //Status
                                                 break;     
                                            //Subtraction
                                            case '-':
                                                 top = intStack.pop(); //Pop top number
                                                 System.out.println(">Popping " + top + " from stack."); //Status
                                                 next = intStack.pop(); //Pop next number
                                                 System.out.println(">Popping " + next + " from stack."); //Status
                                                 result = next - top; //Subtract them
                                                 System.out.println(">Calculating " + next + " - " + top); //Status
                                                 intStack.push(result); //Push result back onto stack
                                                 System.out.println(">Pushing result of " + result + " to stack."); //Status
                                                 break;
                                            //Invalid Characters
                                            default:
                                                 //Ignore them if they're spaces
                                                 if(!Character.isSpaceChar(lineContent.charAt(i))) {
                                                      //So if they're not spaces give an error and exit
                                                      System.out.println("Error:\tInvalid character read. Exiting program...");
                                                      System.exit(1);
                                                      break;
                             //Checking for the "::" that the toString method prints between integers
                             //when there is more than one left in the stack. If there is more the one
                             //integer left in the stack then give an error and exit.
                             for(int i = 0; i < intStack.toString().length(); i++) { //looping through the toString
                                  //if there are two colons, consecutively, there is more than one integer in the stack
                                  if(intStack.toString().charAt(i) == ':' && intStack.toString().charAt(i+1) == ':') {
                                       System.out.println("Error:\tMore than one integer in final stack. Make sure equations\n\tin " + param[0] + " are valid. Exiting program...");
                                       System.exit(1);
                             //Once it passes that check, print the final calculation
                             System.out.println("***The final result is " + intStack.toString() + "***");
                             //Clear the stack for the following loop
                             while(!intStack.toString().equals("Empty Stack")) {
                                  intStack.pop();
                             //Increment the line number and loop back
                             line++;
                        //If it's the end of the file, exit
                        System.exit(1);
                   //catch invalid postfix equations
                   catch(Exception e) {
                        System.out.println("\nError:\tThe " + e + " occured while reading " + param[0] +".\n\tMake sure equations in " + param[0] + " are valid. Exiting program...");
                        System.exit(1);
              //The user entered more than one parameter
              else {
                   //Give the error and exit
                   System.out.println("Error:\tToo many parameters. One file name parameter is allowed. " + param.length + " were found. Exiting program...");
                   System.exit(1);
    /* a stack of ints implemented using a linked list of nodes
    * @author     Biagioni, Edoardo
    * @assignment     lecture 8 and homework 4
    * @date     February 6, 2008
    class IntLinkedStack implements IntStackInterface {
        /* only need to store a single pointer to the node holding
         * the top of the stack.
         * The pointer is null if the stack is empty.
        private IntNode top;
        /* no-arguments default constructor creates an empty stack */
        public IntLinkedStack() {
         top = null;          // start with an empty stack
        /* @return     whether the stack is empty */
        public boolean empty() {
         return (top == null);
        /* @param     int to push onto the stack */
        public void push(int value) {
         top = new IntNode(value, top);
        /* @return     the top int on the stack */
        public int pop() throws EmptyStackException {
         if (empty()) {
             throw new EmptyStackException();
         int result = top.getValue();
         top = top.getNext();
         return result;
        /* convert the stack to a printable string
         * @return     a string representing the stack
        public String toString() {
         if (empty()) {
             return "Empty Stack";
         } else {
             return recursiveToString(top);
        /* recursive method to print a non-empty stack
         * @param     the starting index in the array
         * @return     a string representing the stack
        private String recursiveToString(IntNode start) {
         if (start == null) {
             return "";
         String separator = "";
         if (start != top) {
             separator = " :: ";
         return recursiveToString(start.getNext()) +
                    start.getValue() + separator;
        // simple test
        public static void main(String[] args) {
         IntStackInterface s = new IntLinkedStack();
         System.out.println("before pushing anything, " + s);
         s.push(999);
         s.push(216);
         System.out.println("after pushing 999 and 216, " + s);
         System.out.println("pop returns " + s.pop());
         System.out.println("after popping, " + s);
         // push 100 values
         for (int i = 0; i < 100; i++) {
             s.push(i);
         // now pop them and make sure the same values are returned
         // in LIFO order
         for (int i = 99; i >= 0; i--) {
             int returned = s.pop();
             if (returned != i) {
              System.out.println("error: pop returns " + returned +
                           ", expected " + i);
         s.push(477);
         s.push(381);
         s.push(888);
         System.out.println("after pushing 477, 381, 888, " + s);
         System.out.println("pop returns " + s.pop());
         System.out.println("pop returns " + s.pop());
         System.out.println("pop returns " + s.pop());
         System.out.println("pop returns " + s.pop());
         System.out.println("after popping, " + s);
         /* expected output:
        private class IntNode {
            /* two fields, the first to store the item itself,
             * the second is a pointer to the next node in the linked list.
          * If there is no next node, the pointer is null.
         private int item;
         private IntNode nextNode;
         /* constructor:
          * @param     value, the value for the node
          * @param     next, the next node in the linked list
         public IntNode(int value, IntNode next) {
             item = value;
             nextNode = next;
         /* accessor methods -- since there are no mutator methods,
          * each node is immutable.
         public int getValue() {
             return item;
         public IntNode getNext() {
             return nextNode;
    /* an interface to a stack of ints
    * @author     Biagioni, Edoardo
    * @assignment     lecture 8 and assignment 4
    * @date     February 6, 2008
    * @inspiration     William Albritton's integer stack and Java's stack class,
    *http://www2.hawaii.edu/~walbritt/ics211/stackArray/IntegerStackInterface.java
    * http://java.sun.com/j2se/1.5.0/docs/api/java/util/Stack.html
    interface IntStackInterface {
        /* @param     string to push onto the stack */
        void push(int value);
        /* @return     the top string on the stack */
        int pop()
         throws java.util.EmptyStackException;
        /* @return     whether the stack is empty */
        boolean empty();
    }and this is the file i tested it on:
    98-
    1 1 +
    7 2 /
    8 1 1 + /
    2 3 * 1 -
    5 5 + 2 2 * -
    8 2 / 9 3 / +
    2 2 * 2 *
    1 2 3 1 + * +
    2 6 + 3 - 2 *The outcome should be 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
    Thanks in advance, any help would be appreciated!

    AnthonyJK wrote:
    Thanks, I'm working on breaking it into methods now.Good.
    I also whipped something up,but I currently don't have access to a compiler so there might be errors in it. It's basically the same as what your big main method does, but in a much more readable manner:
    public class KinseyAnthony4 {
         * @param a     the first number
         * @param op    the mathematical operator
         * @param b     the second number
         * @return      the outcome of the expression 'a <op> b'
        private static int evaluate(int a, char op, int b) {
            switch(op) {
            case '+': return a+b;
            case '-': return a-b;
            case '*': return a*b;
            case '/': return a/b;
            default: throw new RuntimeException("Unknown operator: "+op);
         * @param calcMe    the File in which the expressions are stored.
         * @return          the expressions as an array of Strings.
        private static String[] readLinesFrom(File calcMe) throws FileNotFoundException {
            List<String> lines = new ArrayList<String>();
            Scanner readIt = new Scanner(calcMe);
            while(readIt.hasNextLine()) {
                String line = readIt.nextLine();
                line = line.replace(" ", ""); // remove all white spaces
                lines.add(line);
            return lines.toArray(new String[]{});
         * @param param     one parameter needed: the file containing the expressions
        public static void main(String[] param) throws FileNotFoundException {
            if(param.length != 1) {
                System.out.println("usage: java KinseyAnthony4 FILENAME");
                System.exit(666);
            String[] expressions = readLinesFrom(new File(param[0]));
            for(String exp: expressions) {
                System.out.println("\nLINE = "+exp);
                IntLinkedStack stack = new IntLinkedStack();
                for(char ch: exp.toCharArray()) {
                    if(ch >= '0' && ch <= '9') {
                        int digit = Character.getNumericValue(ch);
                        System.out.println("push: "+digit);
                        stack.push(digit);
                    } else {
                        int b = stack.pop();
                        int a = stack.pop();
                        System.out.println("pop: "+a);
                        System.out.println("pop: "+b);
                        System.out.println("calculating: "+a+" "+ch+" "+b);
                        int temp = evaluate(a, ch, b);
                        System.out.println("push: "+temp);
                        stack.push(temp);
                int result = stack.pop();
                System.out.println("***The final result is "+result+"***");
    }Now as to your problem: you see that the pop() method throws an exception? You can wrap the necessary lines of code between *try { ... } catch(...) { ... }* statements to catch the exception when an expression in malformed. I hope that makes a bit sense to you, if not, post back.
    Good luck.

  • "method (...) not found in class (...)" problem

    I am having trouble with my GUI class not recognizing methods from a STACK class from the same package. Here's the skinny:
    I have a GUI class named WordGUI.
    I hava a STACK class named WordStack.
    within WordGUI I instantiate an instance of a WordStack and call it myStack. Example below:
    WordStack myStack = new WordStack();
    When I call WordStack methods from WordGUI I get the error message even though display is a method from WordStack:
    "WordGUI.java": Error #: 300 : method display(java.awt.Graphics, int) not found in class assign4.WordStack at line 34, column 13
    Complete code for both classes is below:
    WordGUI class:
    package assign4;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    public class WordGUI extends Applet implements ActionListener{
    WordStack myStack = new WordStack();
    private Button testButton;
    private TextField wordField;
    public void init(){
    //add(myStack);
    wordField = new TextField(20);
    add(wordField);
    wordField.addActionListener(this);
    testButton = new Button("Test for palindromes");
    add(testButton);
    testButton.addActionListener(this);
    }//init()
    public void paint (Graphics g){
    g.drawString("Enter a word in the textField above and click", 25, 100);
    g.drawString("the button to check if the word is a palindrome", 25, 115);
    myStack.display(g, 150);
    }//paint()
    public void actionPerformed(ActionEvent event){
    if(event.getSource() == testButton){
    String userInput = wordField.getText();
    myStack.evaluate(userInput);
    repaint();
    }//actionPerformed()
    }//class WordGUI
    WordStack class:
    package assign4;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    public class WordStack implements Cloneable{
    private char[] data;
    private int manyItems;
    public WordStack(){
    final int initialCapacity = 20;
    manyItems = 0;
    data = new char[initialCapacity];
    }//generic constructor
    public WordStack(int initialCapacity){
    if(initialCapacity < 0){
    throw new IllegalArgumentException
    ("initialCapacity too small: " + initialCapacity);
    manyItems = 0;
    data = new char[initialCapacity];
    }//constructor
    public int getCapacity(){
    return data.length;
    }//getCapacity()
    public boolean isEmpty(){
    return (manyItems == 0);
    }//isEmpty()
    public char pop(){
    if(manyItems == 0){
    //throw new EmptyStackException();
    return data[--manyItems];
    }//pop()
    public void push(char item){
    if(manyItems == data.length){
    ensureCapacity(manyItems * 2 + 1);
    data[manyItems] = item;
    manyItems++;
    }//push()
    public void ensureCapacity(int minimumCapacity){
    char biggerArray[];
    if(data.length < minimumCapacity){
    biggerArray = new char[minimumCapacity];
    System.arraycopy(data, 0, biggerArray, 0, manyItems);
    data = biggerArray;
    }//ensureCapacity()
    public String evaluate(String userInput){
    char charToProcess;
    for(int charNum = 0; charNum < userInput.length(); charNum++){
    push(userInput.charAt(charNum));
    }//evaluate()
    public void display(Graphics g, int yLoc){
    for(int i = 0; i < data.length; i++){
    g.drawString("" + data, 25, yLoc);
    yLoc += 15;
    }//display()
    }//class WordStack
    Any help would be appreciated greatly. Thank you

    you need to make your graphics call against the GUI object

  • Java Mapping - Class versions are incompatible (linkage error)

    Hi Friends,
        While testing java mapping in Integration Repository i am getting an error - "Class versions are incompatible (linkage error)". Can anyone plz tell what might be the reason.
    Regards,
    Gowtham Kuchipudi.

    hello
    I have this message but my trace look like this:
      <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Request Message Mapping
      -->
    - <SAP:Trace xmlns:SAP="http://sap.com/xi/XI/Message/30">
    - <Trace level="1" type="B" name="interface activity determination">
      <Trace level="1" type="T">Version 000</Trace>
      <Trace level="1" type="T">Message status 000</Trace>
      <Trace level="1" type="T">Interface action INIT</Trace>
      <Trace level="1" type="T">(must be INIT for a new determination)</Trace>
      <Trace level="1" type="T">Message type BEST EFFORT. -> No determination</Trace>
      <Trace level="1" type="T">Set interface action INIT into *MAST*</Trace>
      </Trace>
      <Trace level="1" type="E">CL_XMS_MAIN-WRITE_MESSAGE_LOG_TO_PERSIST</Trace>
    - <Trace level="1" type="B" name="PLSRV_RECEIVER_DETERMINATION">
    - <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV">
    - <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV_LOCAL">
    - <Trace level="1" type="B" name="CL_RD_PLSRV-ENTER_PLSRV">
      <Trace level="1" type="T">R E C E I V E R - D E T E R M I N A T I O N</Trace>
      <Trace level="1" type="T">Cache Content is up to date</Trace>
      </Trace>
      </Trace>
      </Trace>
      </Trace>
      <Trace level="1" type="B" name="CL_XMS_MAIN-WRITE_MESSAGE_LOG_TO_PERSIST" />
    - <Trace level="1" type="B" name="PLSRV_INTERFACE_DETERMINATION">
    - <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV">
    - <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV_LOCAL">
    - <Trace level="1" type="B" name="CL_ID_PLSRV-ENTER_PLSRV">
      <Trace level="1" type="T">I N T E R F A C E - D E T E R M I N A T I O N</Trace>
      <Trace level="1" type="T">Cache Content is up to date</Trace>
      </Trace>
      </Trace>
      </Trace>
      </Trace>
      <Trace level="1" type="B" name="CL_XMS_MAIN-WRITE_MESSAGE_LOG_TO_PERSIST" />
    - <Trace level="1" type="B" name="PLSRV_RECEIVER_MESSAGE_SPLIT">
    - <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV">
    - <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV_LOCAL">
    - <Trace level="1" type="B" name="CL_XMS_PLSRV_RECEIVER_SPLIT-ENTER_PLSRV">
      <Trace level="1" type="T">number of receivers: 1</Trace>
      <Trace level="1" type="T">Single-receiver split case</Trace>
      </Trace>
      </Trace>
      </Trace>
      </Trace>
      <Trace level="1" type="B" name="CL_XMS_MAIN-WRITE_MESSAGE_LOG_TO_PERSIST" />
      <Trace level="1" type="B" name="PLSRV_MAPPING_REQUEST" />
    - <!--  ************************************
      -->
    - <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV">
      <Trace level="1" type="B" name="CL_XMS_MAIN-CALL_PLSRV_LOCAL" />
    - <!--  ************************************
      -->
      <Trace level="1" type="B" name="CL_MAPPING_XMS_PLSRV3-ENTER_PLSRV" />
    - <!--  ************************************
      -->
      <Trace level="1" type="T">Interface Mapping http://Migdal.co.il/CRM/SAP-CRM/ProposalDeatailsService ProposalDeatailsService_WS2RFC_IM</Trace>
      <Trace level="1" type="T">LinkageError at JavaMapping.load(): Could not load class: xmlpayload</Trace>
      <Trace level="1" type="T">java.lang.UnsupportedClassVersionError: xmlpayload (Unsupported major.minor version 49.0) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:539) at java.lang.ClassLoader.defineClass(ClassLoader.java:448) at com.sap.aii.ibrun.server.mapping.MappingLoader.findClass(MappingLoader.java:158) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at com.sap.aii.ibrun.server.mapping.JavaMapping.load(JavaMapping.java:95) at com.sap.aii.ibrun.server.mapping.JavaMapping.executeStep(JavaMapping.java:45) at com.sap.aii.ibrun.server.mapping.Mapping.execute(Mapping.java:92) at com.sap.aii.ibrun.server.mapping.MappingHandler.run(MappingHandler.java:90) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest(MappingRequestHandler.java:95) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleRequest(MappingRequestHandler.java:68) at com.sap.aii.ibrun.sbeans.mapping.MappingServiceImpl.processFunction(MappingServiceImpl.java:79) at com.sap.aii.ibrun.sbeans.mapping.MappingServiceObjectImpl0_0.processFunction(MappingServiceObjectImpl0_0.java:131) at sun.reflect.GeneratedMethodAccessor296.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187) at $Proxy158.processFunction(Unknown Source) at sun.reflect.GeneratedMethodAccessor428.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sap.engine.services.rfcengine.RFCDefaultRequestHandler.handleRequest(RFCDefaultRequestHandler.java:107) at com.sap.engine.services.rfcengine.RFCJCOServer.handleRequestInternal(RFCJCOServer.java:113) at com.sap.engine.services.rfcengine.RFCJCOServer$ApplicationRunnable.run(RFCJCOServer.java:157) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:102) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172)</Trace>
      <Trace level="1" type="T">Linkage error occurred when loading class xmlpayload (http://Migdal.co.il/CRM/SAP-CRM/ProposalDeatailsService, d7e31f30-53be-11dc-8fbd-ee09c0a8664d, -1)</Trace>
      <Trace level="1" type="T">com.sap.aii.ibrun.server.mapping.MappingRuntimeException: Linkage error occurred when loading class xmlpayload (http://Migdal.co.il/CRM/SAP-CRM/ProposalDeatailsService, d7e31f30-53be-11dc-8fbd-ee09c0a8664d, -1) at com.sap.aii.ibrun.server.mapping.JavaMapping.load(JavaMapping.java:115) at com.sap.aii.ibrun.server.mapping.JavaMapping.executeStep(JavaMapping.java:45) at com.sap.aii.ibrun.server.mapping.Mapping.execute(Mapping.java:92) at com.sap.aii.ibrun.server.mapping.MappingHandler.run(MappingHandler.java:90) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest(MappingRequestHandler.java:95) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleRequest(MappingRequestHandler.java:68) at com.sap.aii.ibrun.sbeans.mapping.MappingServiceImpl.processFunction(MappingServiceImpl.java:79) at com.sap.aii.ibrun.sbeans.mapping.MappingServiceObjectImpl0_0.processFunction(MappingServiceObjectImpl0_0.java:131) at sun.reflect.GeneratedMethodAccessor296.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187) at $Proxy158.processFunction(Unknown Source) at sun.reflect.GeneratedMethodAccessor428.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sap.engine.services.rfcengine.RFCDefaultRequestHandler.handleRequest(RFCDefaultRequestHandler.java:107) at com.sap.engine.services.rfcengine.RFCJCOServer.handleRequestInternal(RFCJCOServer.java:113) at com.sap.engine.services.rfcengine.RFCJCOServer$ApplicationRunnable.run(RFCJCOServer.java:157) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:102) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172) Root Cause: java.lang.UnsupportedClassVersionError: xmlpayload (Unsupported major.minor version 49.0) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:539) at java.lang.ClassLoader.defineClass(ClassLoader.java:448) at com.sap.aii.ibrun.server.mapping.MappingLoader.findClass(MappingLoader.java:158) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at com.sap.aii.ibrun.server.mapping.JavaMapping.load(JavaMapping.java:95) at com.sap.aii.ibrun.server.mapping.JavaMapping.executeStep(JavaMapping.java:45) at com.sap.aii.ibrun.server.mapping.Mapping.execute(Mapping.java:92) at com.sap.aii.ibrun.server.mapping.MappingHandler.run(MappingHandler.java:90) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest(MappingRequestHandler.java:95) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleRequest(MappingRequestHandler.java:68) at com.sap.aii.ibrun.sbeans.mapping.MappingServiceImpl.processFunction(MappingServiceImpl.java:79) at com.sap.aii.ibrun.sbeans.mapping.MappingServiceObjectImpl0_0.processFunction(MappingServiceObjectImpl0_0.java:131) at sun.reflect.GeneratedMethodAccessor296.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187) at $Proxy158.processFunction(Unknown Source) at sun.reflect.GeneratedMethodAccessor428.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sap.engine.services.rfcengine.RFCDefaultRequestHandler.handleRequest(RFCDefaultRequestHandler.java:107) at com.sap.engine.services.rfcengine.RFCJCOServer.handleRequestInternal(RFCJCOServer.java:113) at com.sap.engine.services.rfcengine.RFCJCOServer$ApplicationRunnable.run(RFCJCOServer.java:157) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:102) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172)</Trace>
      <Trace level="1" type="E">CL_XMS_PLSRV_MAPPING~ENTER_PLSRV</Trace>
      </Trace>
      <Trace level="1" type="B" name="CL_XMS_MAIN-WRITE_MESSAGE_TO_PERSIST" />
    - <!--  ************************************
      -->
      </SAP:Trace>
    the error that I recieve in the SXMB is:
      <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Request Message Mapping
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
      <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">LINKAGE_ERROR</SAP:Code>
      <SAP:P1>xmlpayload</SAP:P1>
      <SAP:P2>http://Migdal.co.il/CRM/SAP-CRM/ProposalDeatailsS~</SAP:P2>
      <SAP:P3>d7e31f30-53be-11dc-8fbd-ee09c0a8664d</SAP:P3>
      <SAP:P4>-1</SAP:P4>
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Class versions are incompatible (linkage error)</SAP:Stack>
      <SAP:Retry>N</SAP:Retry>
      </SAP:Error>
    this is my XI information
    Runtime Environment
    Java version:1.4.2_12
    Java vendor:Sun Microsystems Inc.
    Version
    Service pack:21
    Release:30_VAL_REL
    Latest change:409678
    Sync time:200709211024
    since I already have the SP required by the note, any other suggestions?
    Thanks
    Kfir

  • Operations on stack

    Hi guys,
    I've got a simple stack working, but am having some problems with the input commands. Basically, the commands "empty", "pop", and "peek" are only meant to operate on the stack, not to be inserted inside it. They function on it and also operate on it. Any suggestions how this can be fixed? I don't want them to be inserted into my stack, just to operate.
    Heres my code:
    // Code By SSPanesar, 2006
    // this code was made using Java API
    import java.util.*;
    import java.io.*;
    public class Stacks2
    public Stacks2()
             Stack pile = new Stack(); // making a new instance Stack
            String s = "";
            boolean truth = false;
            int check = 0; // used as a counter
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("Please enter some text, and finish with 'end'");
            while (truth == false)
              try
                 s = in.readLine();
              catch(IOException e)
                if(s.equals("end")) // what to enter to end program
                          truth = true;
                    if(s.equals("pop"))
                       if(check==1)
                         System.out.println("stack empty");
                         // truth = true; THIS IS INSERTED HERE TO END THE PROGRAM WHEN THE STACK IS EMPTY (OPTIONAL)
                       else
                             check = check - 1;
                             System.out.println("The value: "+pile.pop()+" has been removed from the stack");
                             System.out.println("The size of the Stack is: "+check);
                if(s.equals("peek")) // reading top value of the program
                        System.out.println("The top value in the stack is: "+pile.peek());
              else
                pile.push(s);
                check = check + 1;
                System.out.println("You Just entered into the Stack :"+s);
              for(int a=0;a<check;a++)
                System.out.println(pile.pop());
            public static void main(String[] args)
               Stacks2 box = new Stacks2();
    }

    ok, so with the code that I have here, is there no
    alteration that can be done to solve this problem?First, you haven't really defined what the problem is, aside from saying that you don't want to define methods like pop() and push() in your Stack class. That doesn't make any sense, and I've pointed you to some resources that tell you why.
    Second, I haven't bothered to dissect your code because it's a bit tough to look at. I recommend that for now, you strictly adhere to the standard Code Conventions for the Java� Programming Language. It will make your code much easier to read, which of course, makes it much more likely you'll get others to look at it.
    Third, don't flag your question as urgent, even if it is for you.
    * We all answer questions here voluntarily, in our leisure time. We do that because doing so is fun for us, because we enjoy helping people and having interesting discussions. Guess what, it is much less fun if it gets stressful. So the last thing you want to do to get us to answer your question is to pass your stress over to us.
    * People who are stressed and want a fast answer often don't even find the time to do the necessary research or to formulate their question in an easy to comprehend way. That's even less fun to work with. So you really don't want us to feel your stress. Instead you want to take your time to write a well formulated post that is fun to answer. The less likely it is for us to know that your question is urgent, the more likely you are to get a fast answer!
    * The simple notion that you want your post to be answered faster than those of the other members might feel rather unfair to some of us. Doubly so because often "urgent" questions actually are homework questions. Yours might be different, but someone who had bad experiences with this type of question might not read far enough to notice.
    So, yes, there is alteration that can (and should be done). Read those links, and research existing example Stack code. There are scads of examples out on the web, and will be easy to find. If you have a specific coding error that you're having trouble working out, make sure you describe the problem specifically.
    Good luck!

  • How to create a generic stack (whose elements can be of any data types) ???

    How do you define a "Stack" class that takes the Data type as its constructor argument ,and creates a new instance of that stack type ??? e.g. Stack("double") should create a stack of doubles ,and so on...
         Putting it in another way, how do you go about defining a Stack ,if you are not sure what data types will be pushed into it at runtime ??? Making a Stack of Objects doesn't seem the appropriate choice since, in that case also, you won't be sure of which of the "parseInt(),paresDouble(),Integer(),Double() etc." functions to retrieve the value.

    Write your own stack class which delegates push and pop calls to an internal instance of the java.util.Stack. In addition the class has an attribute of type Class. When the push method is invoked the object in the argument will be tested whether it is an instance of the class stored in the type attribute. If not an IllegalArgumentException should be thrown.
    Here is the minimal code for such a type-save stack (the main method shows its usage):
    import java.util.Stack;
    public class TypeSaveStack {
        private Stack _stack = new Stack();
        private Class _type;
        public TypeSaveStack(Class type) {
            _type = type;
        public void push(Object element) {
            if (_type.isInstance(element)) {
                _stack.push(element);
            } else {
                throw new IllegalArgumentException(element
                                  + " is not an instance of " + _type);
        public Object pop() {
            return _stack.pop();
        public static void main(String[] args) {
            TypeSaveStack doubleStack = new TypeSaveStack(Double.class);
            doubleStack.push(new Double(Math.PI));
            System.out.println(doubleStack.pop());
            try {
                doubleStack.push("foo");
            } catch (Exception e) {
                System.out.println(e);
    }

  • Help,about why we use inner class?

    Hi,
    when i read "java Tutorial"
    i found there is one chapter about inner class .
    i copy it down as follow.
    the context is about there is a class Stack, and this class want to implement some function of interface Iterator,but as the book said
    we should not let class Stack implement the Iterator directly, we should add a inner class inside the Stack .
    i know it's very import ,but i still can not understand the reason why add a inner class here.
    hope somebody can explain it a little more for me or give an example.
    thank in advance!
    Iterator defines the interface for stepping once through the elements within an ordered set in order. You use it like this:
    while (hasNext()) {
    next();
    The Stack class itself should not implement the Iterator interface, because of certain limitations imposed by the API of the Iterator interface: two separate objects could not enumerate the items in the Stack concurrently, because there's no way of knowing who's calling the next method; the enumeration could not be restarted, because the Iterator interface doesn't have methods to support that; and the enumeration could be invoked only once, because the Iterator interface doesn't have methods for going back to the beginning. Instead, a helper class should do the work for Stack.
    The helper class must have access to the Stack's elements and also must be able to access them directly because the Stack's public interface supports only LIFO access. This is where inner classes come in.
    Here's a Stack implementation that defines a helper class, called StackIterator, for enumerating the stack's elements:
    public class Stack {
    private Object[] items;
    //code for Stack's methods and constructors
    not shown
    public Iterator iterator() {
    return new StackIterator();
    class StackIterator implements Iterator {
    int currentItem = items.size() - 1;
    public boolean hasNext() {
    public Object next() {
    public void remove() {
    or you can visit here
    http://java.sun.com/docs/books/tutorial/java/javaOO/innerclasses.html

    the context is about there is a class Stack, and this
    class want to implement some function of interface
    Iterator,but as the book said
    we should not let class Stack implement the Iterator
    directly, we should add a inner class inside the
    Stack .Simply because the implementation of the Iterator is nobody's business. By declaring it to be a private inner clss, nobody will ever know about it and only see the Iterator interface.

  • XI Mapping: Class versions are incompatible (linkage error)

    Hi,
    i have a simple File-to-File scenario, and I am getting the following error as observed in the XI Monitor:
    <SAP:Category>Application</SAP:Category>
    <SAP:Code area="MAPPING">LINKAGE_ERROR</SAP:Code>
    <SAP:Stack>Class versions are incompatible (linkage error)</SAP:Stack>
    To troubleshoot the mapping, I have removed all mappings, and put the target nodes to constant values. I am still getting the error in Mapping (linkage error).
    I am using XI3.0SP0 (J2EE SP07, ABAP SP3). Is this a known problem / OSS notes available ? thanks.
    Regards,
    Manish Agarwal.

    Hallo Agarwal,
    have a look in OSS Message #755302
    Regards Franz Forsthofer

  • Stack ADT using array

    Hi everyone, I posted a similar question earlier and thought I got the response I wanted but I keep running into problems.
    I'm looking to make my own version of the stack ADT using arrays (or arraylist).
    I have created my own isEmpty() method. Here is part of my code:
    public interface StackADT<T> {
         void push(T element); // adds an element to the stack
         T pop(); // removes an element from the stack and returns it
         boolean isEmpty(); // returns true if the stack is empty and false otherwise
         T peek(); // returns top element from the stack without removing it
         void truncate(); // truncates the stack to the exact number of elements
         void setExpansionRule(char rule); // sets expansion to either doubling or increasing by 10 elements
    public class Stack<T> implements StackADT<T> {
              private T[] array;
              int index = 0;
              public Stack(){
                   this.array = (T[]) new Object[50];
              public boolean isEmpty(){
              if (index == 0){
                   return true;
              return false;
               public T pop(){
                    if(Stack<T>.isEmpty()){  //ERROR
                     throw new EmptyStackException("Stack is empty");     
    }I'm trying to use my isEmpty() method (also part of the stack class) inside other methods like pop(). Problem is it says: "T cannot be resolved to a variable, Stack cannot be resolved to a variable". I also tried Stack.isEmpty(), but it doesn't work. I'm really confused. Any suggestions?
    Edited by: Tiberiu on Mar 1, 2013 6:38 PM

    >
    Hi everyone, I posted a similar question earlier and thought I got the response I wanted but I keep running into problems.
    I'm looking to make my own version of the stack ADT using arrays (or arraylist).
    I have created my own isEmpty() method. Here is part of my code:
    >
    No - you haven't. There is no 'isEmpty' method in the code you posted.
    We can't debug code that we can't see. You haven't posted any interface and you haven't posted anything that calls any of the limited code that you did post.
    You did post code that tries to call the method on the class instead of an instance of the class.
    if(Stack<T>.isEmpty()){ 

  • Stack implementation

    I need help in my assignment to implment a stack with push and pop functions. if anyone is an expert in this section pliz help me out.....

    If you want a good implementation look at the source
    code for java.util.Stack.That Stack class is not a good implementation of a stack for a couple
    of reasons:
    1) it extends the Vector class which uses synchronized methods, which
    you often don't want. The Stack class had better been retrofitted on a
    WhatEverList implementation of the List interface, but even then:
    2) The base class (WhatEverList or Vector) is too strongs for a Stack
    class, i.e. you don't want to be able to, say, remove elements from the
    middle from a stack or take the intersection with another Collection.
    kind regards,
    Jos

Maybe you are looking for

  • Our accountant is no longer allowed access to the QuickBooks file

    My main server is Small Business Server 2008 Standard (i.e. pre-R2).  I have another box running Server 2012 that's just acting as a Hyper-V host.  On that server I have three relevant VMs, all Windows 7 Professional and joined to the domain. One is

  • Unable to confirm TO - Getting VL659 error Message

    Hi Experts, An Inbound Delivery is created and 26 TO's created for each HU. 25 TO's are confirmed. Now while Confirming one TO getting an error message VL659 - (Error when creating document flow for delivery.) Can some one please help as it is a stan

  • Canon 5D MK II white balance set as K does not import correctly

    With a 5D II and the Kelvin white balance set in the camera the WB does not import correctly for RAW files and LR 2.4. For example when set to a specified white balance as a Kelvin setting, for example 5200, and then import the raw files with "As Sho

  • Broken ADOBE Link for CS3 System Requirements?

    The link for general CS3 systemm requirements at http://www.adobe.com/products/premiere/systemreqs seems to work, but ... Does this link, http://www.adobe.com/products/premiere/dvhdwrdb.html for the full compatible hardware listing for the video card

  • I want to update my browser

    I'm trying to get onto my website host Wix.com and the page won't open for me