A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Spring in Action
this week in the
Joined: Dec 02, 2008
Dec 02, 2008 07:10:00
if static methods are restricted to call only staic methods and data,
how can main() be static and yet call any kind of methods or data.
Joined: Feb 28, 2007
Dec 02, 2008 07:40:00
Welcome to JavaRanch!!!
How do you find your statement to be correct?
Can you come up with an example?
Static method can't access non-static method or instance member, because
there is no "this" reference in it. The same applies to main() method also.
Joined: Aug 05, 2005
Dec 02, 2008 08:03:00
Can we carry on the discussion of this question in
this duplicate post
I agree. Here's the link:
subject: Static mmbers
static and non-static synchronized methods
non-static variable cl cannot be referenced from a static context
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014