aspose file tools
The moose likes Beginning Java and the fly likes how to use the final class that has no constructor? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "how to use the final class that has no constructor?" Watch "how to use the final class that has no constructor?" New topic
Author

how to use the final class that has no constructor?

Tanakorn Numrubporn
Ranch Hand

Joined: Dec 11, 2006
Posts: 81
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
Every class has a constructor.


42
Pavel Kubal
Ranch Hand

Joined: Mar 13, 2004
Posts: 356
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
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...


"I'm not back." - Bill Harding, Twister
Tanakorn Numrubporn
Ranch Hand

Joined: Dec 11, 2006
Posts: 81
http://www.cs.vu.nl/ibis/api/index.html

Thank you for every reply.
This is the link for that API.
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1295
Originally posted by Tanakorn Numrubpor:
http://www.cs.vu.nl/ibis/api/index.html

Thank you for every reply.
This is the link for that API.


What's the name of the class you were trying to use?


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Tanakorn Numrubporn
Ranch Hand

Joined: Dec 11, 2006
Posts: 81
oop! sorry the class is GruopMessage
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
So, have you tried simply calling "new GroupMessage()" like I suggested?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 8145
    
  52

Since i dont see any non-default constructors mentioned in that Javadoc, the default constructor should work:



[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use the final class that has no constructor?
 
Similar Threads
A constructor cannot be final, static or abstract. Why ?
Loading class outside of classpath and running its method ??
constructor concepts...
Why Integer class has Constructor
Preventing instantion of base class object