Results 1 to 2 of 2
  1. #1
    mathias is offline Member
    Join Date
    Jul 2007
    Rep Power

    Default I am confused about is the "add" method...

    Hi, I am having some major problems with a piece of work involving Java.
    We have been giving the following:

    Java Code:
    static int add(int chain, int value)
    // here you need to provide the code that adds a new element to the front of the chain
    // my solution has four lines ...
        return NULL; // this line is only here so you can compile and run the code as is.
      } // end of method "add"
    We are supposed to simulating the "Heap".

    Then later we have this:
    Java Code:
    static public void main(String args[])
                System.out.println("start of program");
                int myChain = NULL;	// initialise the chain ...
                int values [] = {76, 42, 33, 29, 50};	
                for (int i = 0; i < HEAP_SIZE; i++)
                   heapArray[i] = new HeapElement();
                for (int i = 0; i < 5; i++) {
    				System.out.println(myChain = add(myChain,values[i]));
                System.out.println("end of program");
    I need to add the values in the "values" Array into specific random points allocated earlier in the program.

    But the bit I am confused about is the "add" method, and the way it is used, specifically, what does this mean?
    Java Code:
    myChain = add(myChain,values[i]

  2. #2
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Rep Power


    So is everyone else that looks at it. I would take that back to whoever gave it to you and have them explain themselves. From the snippet of code you provided it is difficult to understand the purpose of the myChain variable and why it is being assigned there.

Similar Threads

  1. Hwlp with "Open", "Save", "Save as..."
    By trill in forum New To Java
    Replies: 3
    Last Post: 11-02-2010, 09:26 AM
  2. Replies: 6
    Last Post: 10-27-2008, 12:25 AM
  3. Replies: 1
    Last Post: 07-27-2007, 10:59 PM
  4. Replies: 1
    Last Post: 07-25-2007, 10:55 PM
  5. Replies: 1
    Last Post: 07-16-2007, 06:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts