how to use the final class that has no constructor?
Tanakorn Numrubporn
Ranch Hand
Joined: Dec 11, 2006
Posts: 81
posted
0
I using Ibis (Grid computing API on java base) and I find one final class that I think I have to use it. It has no constructor, so I can't instantiate it. Api doc tells me that this class is class container, which comprises multiple field that I want to use it but I can't.
Please help me
Thank you Tanakorn
Jeroen T Wenting
Ranch Hand
Joined: Apr 21, 2006
Posts: 1847
posted
0
Every class has a constructor.
42
Pavel Kubal
Ranch Hand
Joined: Mar 13, 2004
Posts: 356
posted
0
Did you look for some factory methods?
Every class has a constructor, but not every constructor is visible.
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
Another possibility: if a class has no declared constructor, then a default constructor will be automatically created, with no arguments. So just calling "new SomeClassName()" should work.
Now if the class has a constructor, but it's private - that's when you may have to look for another way to create it, such as a factory method. Or, some classes are not intended to be instantiated. (See java.lang.Math for example.) You may have to study the API more to understand how the class is to be used. Or if you can give a link to the API of this class, maybe we can help...