Why there are no global variables in Java?


Global variables are globally accessible. Java does not support globally accessible variables due to following reasons:
1)The global variables breaks the referential transparency
2)Global variables creates collisions in namespace.

Leave a Reply

Your email address will not be published. Required fields are marked *