| Author |
Unable to add an element to an arraylist using extended class
|
Jon Kho
Ranch Hand
Joined: Jun 03, 2009
Posts: 54
|
|
Dear all,
I am facing a problem of using an class which is a sub class of another. Using in the sense, putting the attributes of the extended class into the arraylist that initially uses the original class for the main class. I hope to understand more about this problem. Here are the codes..
any comments or help on this topic will be great.
regards,
Jon
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16811
|
|
I am facing a problem of using an class which is a sub class of another.
I am assuming that the problem that you are facing, is that it won't compile? As neither of the two classes have constructors that has the same name as the class. (and if they are methods, then they don't have a return type).
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Jon Kho
Ranch Hand
Joined: Jun 03, 2009
Posts: 54
|
|
Hi Henry,
Thanks for replying.
Actually I am using the methods like this.
and it shows this when i highlight it.
incompatible types
found CompactDisc
required: DVD
any comments or help on this topic would be great!
thanks
|
 |
Jon Kho
Ranch Hand
Joined: Jun 03, 2009
Posts: 54
|
|
dear all,
does this thread able to help me to solve the current problem? Now I am trying to figure out the function of the "buffer"...
any comments or help on this thread would be great!
edit: This above coding does not work on my coding because the current class has this..
public class DVD extends CompactDisc {
also i found an example from here which i understand but i am unable to implement it on the code which i have..
Regards,
Jon
|
 |
 |
|
|
subject: Unable to add an element to an arraylist using extended class
|
|
|