how to use the final class that has no constructor?
Joined: Dec 11, 2006
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
Joined: Apr 21, 2006
Every class has a constructor.
Joined: Mar 13, 2004
Did you look for some factory methods?
Every class has a constructor, but not every constructor is visible.
Joined: Jan 30, 2000
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...