Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to add an element to an arraylist using extended class

 
Jon Kho
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20995
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jon Kho
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic