A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
Static mmbers
jack worthing
Greenhorn
Joined: Dec 02, 2008
Posts: 18
posted
Dec 02, 2008 07:10:00
0
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.
Chandra Bhatt
Ranch Hand
Joined: Feb 28, 2007
Posts: 1707
posted
Dec 02, 2008 07:40:00
0
Hi Jack,
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.
cmbhatt
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
9
posted
Dec 02, 2008 08:03:00
0
Can we carry on the discussion of this question in
this duplicate post
Joanne
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: Static mmbers
Similar Threads
static and non-static synchronized methods
Static mmbers
understanding static
static
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