What is difference between static and global variable in java?

匿名网友 匿名网友 发布于: 2015-08-30 00:00:00
阅读 154 收藏 0 点赞 0 评论 0

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.

评论列表
文章目录