aspose file tools*
The moose likes Beginning Java and the fly likes Abstract Classes initialization parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstract Classes initialization parameters" Watch "Abstract Classes initialization parameters" New topic
Author

Abstract Classes initialization parameters

Dennis M Kavanagh
Greenhorn

Joined: Mar 26, 2007
Posts: 6
Hello,

I have three classes.

One is a DataSetRequestor with various fields filled in by the user.

I have an abstract class called DataSet holdoing commonalities, with subclasses for each specific type of DataSet.

I need to get some values from the DataSetRequestor class to the abstract class as initialization parameters.

Any thoughts?

Thank You
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
You can pass parameters to an abstract class’ constructor.
You can create an anonymous subclass by implementing any abstract methods.

Other people will doubtless think of other ways to do it.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Using the constructor is a good way, but you would have to require each of the subclasses to call this constructor. You could also provide a setter method in the abstract class to pass in those parameters.

By the way, the fact that your DataSet class is abstract is completely irrelevant to this question. Remember that despite what you said,
I need to get some values from the DataSetRequestor class to the abstract class as initialization parameters.

you are not passing those values to the class. You are passing them to an object which is an instance of that class. So you would just use any suitable method for passing values into an object.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract Classes initialization parameters