java static variable

java static variable
/**
 * @author lautturi.com 
 * Java example: java static variable in Class
 */

import java.util.*;
import java.util.regex.Pattern;

class Car {
	String name;
    static int count; 
    public Car(String str) {
    	this.name = str;
        count++;
    }
}

public class Lautturi {
	public static void main(String[] args){
		Car c1 = new Car("BMW");
		Car c2 = new Car("Ford");
    
    	System.out.println("car counts: " + Car.count); 
		
	}
}
Source:w‮uttual.ww‬ri.com

output:

car counts: 2
Created Time:2017-09-30 16:26:56  Author:lautturi