Horje
java static variable Code Example
java static variable
// A static variable is shared among all objects of a class
class Slogan {
	String phrase; // string description of slogan
    static int count; // slogan count    
    public Slogan(String phrase) {
    	this.phrase = phrase;
        count++;
    }
}

public class SloganCounter {
	public static void main(String[] args) {
    	Slogan slg1 = new Slogan("Live free or die!");
        Slogan slg2 = new Slogan("Don't worry, be happy!");
    
    	System.out.println("Slogans count: " + Slogan.count); 
        // Above outputs: Slogans count: 2
    }
}



java static variable

Person notReallyAPerson = null;
notReallyAPerson.qtdone++; // this works!





Java

Related
minecraft java Code Example minecraft java Code Example
java get current date without time Code Example java get current date without time Code Example
round off java 2 decimal places Code Example round off java 2 decimal places Code Example
android studio float to int Code Example android studio float to int Code Example
isblank vs isempty Code Example isblank vs isempty Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7