What is difference between static and global variable in java?

2010年11月16日 01:20 阅读 16 Java

1. Static variables:
Static or class variables are initialized when the class is loaded into the JVM. These static variables usually can be accessible without creating instance of a class. Mostly it is used to declare constant values.
2. Global variables:
AFAIK, java doesn’t support global variable but however you can declare variables as public which can be accessed by inside/outside classes/packages.

还没有评论!