Let's learn about Global variables,
Global variables are the variables that we declare inside the class but outside the method, and that variable can use through out the program scope, that means you can use that variable in any method of that class.
Let's use global variable in a program,
Here I'm going to static key word to declare the variable because we are about to use the variable we create in side the main method, main method is a static method so we can't use non-static things inside the static one without creating a object. As we don't know about the Object Oriented Programming yet just follow the code and get the idea of Global Variable.
Beginners Lab Assignments Examples
ReplyDelete