• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

overriding methods in AbstractCollection

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am trying to implement a class that inherits from AbstractCollection, the abstract class, but I don't know how to "add" to the collection. There is no actual container like array or vector provided in AbstractCollection class, so how do I implement an "add" or "remove" to a class that extends from AbstractCollection?
Thanks!
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public abstract class AbstractCollection{
//constructor
AbstractCollection(){

}
//you can override methods here
}
public class Collection extends AbstractCollection{

//constructor
blah, blah
//you want to change base class method here
...

//your class's own method like add(), remove()
void add(...){
}
void remove(...){

}
}
Is this answer your question?
read "thinking in java", very good book.
 
ricky gonzalez
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I was thinking more of the physical implementation of a class that overrides the add/remove methods in AbstractCollection. For instance, a queue that goes like a, b, d, e, f, and you wish to "add" a c so that as a whole the queue becomes a, b, c, d, e, f. How do you access the inner container within AbstractCollection to add/remove?
Thanks!
 
ricky gonzalez
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, somebody please help!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic