GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes can i call a consturctor from a static method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "can i call a consturctor from a static method?" Watch "can i call a consturctor from a static method?" New topic
Author

can i call a consturctor from a static method?

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
what is the format for calling a constructor ?
can i call a constructor from a non-static method ?
can i call a constructor from a static method or block?


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

This is one of those questions that can be answered by testing it yourself.
If I answer the first question for you:

You should be able to discover the answers to the other two questions yourself.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257

Hello,

Along with those,

try,

1) Static block
2) Object block ( which will be executed before constructor)

They will give good insight into object state loading.
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Originally posted by Srinivas Kalvala:
Hello,

Along with those,

try,

1) Static block
2) Object block ( which will be executed before constructor)

They will give good insight into object state loading.


I don't see how. By "object block" are you referring to an instance initializer?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Moving to the beginners forum...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Dana Bothner-By
Ranch Hand

Joined: Jul 28, 2006
Posts: 37
Originally posted by saikrishna cinux:
what is the format for calling a constructor ?


You've entered more than 400 posts and you haven't created an object yet? Just what have you been doing?
Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257

Originally posted by Ken Blair:

I don't see how. By "object block" are you referring to an instance initializer?



Yes Ken, you are Right.
 
GeeCON Prague 2014
 
subject: can i call a consturctor from a static method?