Each Java class file acts as both the interface declaration and the implementation of the object. In Java every constant must be declared as public final within a class. The constant Pi is defined as java.lang.Math.PI . No global variables In a programing language, like C, a variable is considered global if it can be access and refered from anywhere in the program. Java does not support global variables .
Every variable is declared within a class and forms part of that class .
This is one of the principal of Object Oriented programing where everything has to be part of a class and and nothing can exists outside a class . The closest thing from a global variable are instance class variables . Those variables are available within the class where they are declared and if the are declared public , can be access from other classes but they will always be part of the class where they belong. Every class is part of a package . A package name consists of different names separate by periods.