Worked example
class Dog {
String name;
int age;
Dog(String n, int a) { // constructor: same name as the class
name = n;
age = a;
}
}
Dog d = new Dog("Rex", 3); // constructor runs, sets the fields
Now d.name is Rex and d.age is 3 the moment the object is built.