main method in java

Hello Sir ,

I am new to java .

I have a question. And i am not getting its satisfactory answer.

We know that a static method can only access static variables in a class.

Then how can a main method which is also static method can access non static variables?

Plz help me

Yhanx in advance.

[330 byte] By [chahalkhushwindera] at [2007-11-27 2:37:17]
# 1
> We know that a static method can only access static> variables in a class.Without using an object reference, yes.> Then how can a main method which is also static> method can access non static variables?It can't.
CeciNEstPasUnProgrammeura at 2007-7-12 2:57:20 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanx a lot for answer did it mean that a main method can access static variables only with an object?
chahalkhushwindera at 2007-7-12 2:57:20 > top of Java-index,Java Essentials,Java Programming...
# 3
No object is required to access the static variable. Static variables can be accessed using class name.
AnanSmritia at 2007-7-12 2:57:20 > top of Java-index,Java Essentials,Java Programming...
# 4

> did it mean that a main method can access static

> variables only with an object?

Huh? No. I don't see how I would have said that. It's actually something you're not supposed to do.

By the way, it's very easy to write some test code to see yourself, instead of asking.

CeciNEstPasUnProgrammeura at 2007-7-12 2:57:20 > top of Java-index,Java Essentials,Java Programming...
# 5
okay :(thanx
chahalkhushwindera at 2007-7-12 2:57:20 > top of Java-index,Java Essentials,Java Programming...