Author
question about maths class
Kartik Mahadevan
Ranch Hand
Joined: Feb 16, 2005
Posts: 44
Hi Why r we not able to make statements like Maths a = new Maths(); I assume that constructors r private but is there a way in which we can access them. Regards Kartik
Thomas Paul Bigbee
Ranch Hand
Joined: Jun 28, 2005
Posts: 71
The math class cannot be instantiated, it consists of a bunch of static methods
Kartik Mahadevan
Ranch Hand
Joined: Feb 16, 2005
Posts: 44
Hi but is it necessary that classes which have a bunch of static methods cannot be initialized. Regards M.Kartik
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24048
The java.lang.Math class has no public constructors, deliberately, simply because it would make no sense to have a java.lang.Math object. There are some other classes like this: java.lang.System is one. Why do you want to do this?
[Jess in Action] [AskingGoodQuestions]
Kartik Mahadevan
Ranch Hand
Joined: Feb 16, 2005
Posts: 44
Sir I just wanted to check that if i make a class and make it's constuctors private nobody could make objects of that class. Thanks Kartik
Megs Maquito
Ranch Hand
Joined: May 18, 2005
Posts: 84
i think another advantage of a class having a private constructor and static methods is, it saves memory as it doesn't go on the heap.
I'm a Hood Ornament
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35232
posted Sep 05, 2005 07:02:00
0
I just wanted to check that if i make a class and make it's constuctors private nobody could make objects of that class
You can do that by just creating such a class of your own, and simple checking if it is possible, no?
Android apps – ImageJ plugins – Java web charts
subject: question about maths class