Java examples for Object Oriented Design:Constructor
A Cat Class with a Constructor
public class Main { public static void main(String[] args) { // Create a Cat object and ignore its reference new Cat();/* w w w. j a v a 2s . c o m*/ // Create another Cat object and store its reference in c Cat c = new Cat(); } } class Cat { public Cat() { System.out.println("Meow..."); } }