25
loading...
This website collects cookies to deliver better user experience
Class Cat
{
String name; // Non-static variable (each object has it's own copy)
static int catCount; //Static variable (each object of the class Cat shares this variable
Cat(String name){
this.name = name; // Non-static variables can be referenced with "this" keyword
Cat.catCount++; // Static variables are referenced using the class name
}
Cat sally = new Cat();
String name = sally.getName();
Cat sally = new Cat();
String name = Cat.getName(sally);
25