This week's book giveaway is in the Agile forum.
We're giving away four copies of The Software Craftsman and have Sandro Mancuso on-line!
See this thread for details.
The moose likes Java in General and the fly likes Copy Constructor help. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Copy Constructor help." Watch "Copy Constructor help." New topic

Copy Constructor help.

Andrew Gary

Joined: Aug 31, 2011
Posts: 8

I'm having trouble making a copy constructor for this ListType class, the list type class implements the GeneralList interface, which is down below the ListType class.

I have to create a copy constructor that accepts a reference to another GeneralList Object.

Here is the ListType class

And here is the GeneralList interface

Here is what I have come up with, but it does not work.
Could someone help me understand why this copy constructor does not work, and how to modify it so that it does work?

Thanks for any help, it's much appreciated.

Thanks in advance.
Praveen Kumar M K
Ranch Hand

Joined: Jul 03, 2011
Posts: 256
Hi Andrew,

In the copy constructor, you are not setting the value of the number of elements. Although the "list" array has the right values, elements is still = 0.
Andrew Gary

Joined: Aug 31, 2011
Posts: 8

Oh thanks! I never catch my own stupid mistakes ha. Appreciate the help!!
jQuery in Action, 2nd edition
subject: Copy Constructor help.