Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2007, 10:03 PM
Member
 
Join Date: Jul 2007
Posts: 40
mathias is on a distinguished road
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:

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:
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?
Code:
myChain = add(myChain,values[i]
Thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-01-2007, 06:29 AM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error! "filename" is not abstract and does not override abstract method... hasani6leap New To Java 4 01-06-2008 05:59 PM
Hwlp with "Open", "Save", "Save as..." trill New To Java 1 07-31-2007 08:53 AM
Exception in thread "main" java.net.ConnectException: Connection timed out osval Advanced Java 1 07-27-2007 11:59 PM
Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException romina New To Java 1 07-25-2007 11:55 PM
ArrayList: Exception in thread "main" java.lang.NullPointerException susan New To Java 1 07-16-2007 07:32 AM


All times are GMT +3. The time now is 06:57 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org