main() is a static method and is part of class. Then how is it that main can access instance members?
cvanithakpm
0
Newbie Poster
Recommended Answers
Jump to PostStatic methods can not directly access any instance variables or methods but they can access them by using their object reference.
Static methods may even access private instance variables via a object reference.
All private instance variables are private to its class, they can be accessed by static methods or …
Jump to Posthow is it that main can access instance members?
Do you have an example where that is done? Please post it.
All 6 Replies
poojavb
29
Junior Poster
NormR1
563
Posting Sage
Team Colleague
kramerd
29
Posting Pro in Training
NormR1
563
Posting Sage
Team Colleague
stultuske
1,116
Posting Maven
Featured Poster
richieking
44
Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.