File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Unable to add an element to an arraylist using extended class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Unable to add an element to an arraylist using extended class" Watch "Unable to add an element to an arraylist using extended class" New topic
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: 18509
    
  40

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to add an element to an arraylist using extended class
 
Similar Threads
Persisting pojo with collection attribute using Hibernate
struts beginner question
Unable to compile class for JSP
Unresolved Method?
For varsity...