Hello,
Global varriable which is defined after the class tag and before Method. so there are two type of Global variable
1.Instace global variable
public class GolbalVariable{
public String username;
public String password;
}
Explanation : this is called as instance variable . so on instance method you can access directly . suppose if you want to access inside statioc method then create Object of class and access it . if method is static then code to access the variable,
ClassObject obj=new ClassObject();//create class Object from static method
username;//if username is static
obj.username; // if username is instance
2.static global variable.
public class GolbalVariable{
public static String username;
public static String password;
}
Explanation : You can access directly with class Name
ClassObject obj=new ClassObject();//create class Object from static method
obj.username;//if username is static
Hope this is helpful!
Thank You!!