hello, everybody....
i am new to java programming........so my question may be childish
i want to ask that.....in java all methods and variables are public...
by default(opposite to c++).so why we are writing public static void main(String args[]).main method can be accesed from anywhere
even if i dont write public bcoz it is by default public

Recommended Answers

All 2 Replies

Not quite. The default access modifier makes things public only to the same package. Any class in another package will not be able to access the methods/members.

thnak you......

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.