Witscale Test Center

3.8 Constructors and modifiers > 3.8.4 Constructor with public access


3.8.4 Constructor with public access

When a class has public constructor, any Java class that can access the class, can access the constructor as well
and create instances of that class. In listing 3.21, class Product has a public constructor.

 

In this example, the class Tester from another package can access the public constructor of Product to create the objects of the Product class.