User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







java:variables:global_variable

global variable

define a global variable in java, after the public class block

example of global varialbe in java

 package codereferececomjava;
 
public class CodeRefereceComJava {
 
    public static int globalDigit; // define a global variable
 
    public static void main(String[] args) {
 
        int digit = 5; // define and inital a local variable
        globalDigit = digit; // initalisize the global variable
 
        funct(); // call funct();
    }
 
 
    public static void funct() {
        System.out.println(globalDigit); // print out the global variable
    }
 
}
 

output of global variable

   42
advertising
java/variables/global_variable.txt · Last modified: 2013/04/16 09:04 by 188.102.43.32

Impressum Datenschutz