What is constructor overloadng?

Constructor overloading is a methodology that allows a class can have any number of constructors that differ in parameter lists. A constructor initialize’s the new object’s state by using its arguments. The compiler differentiates these constructors by taking into account the number of parameters in the list and their types. Constructors are not members of a class, so they are not inherited by subclasses. Therefore, each of the subclasses must specifically implement any constructors it needs. However, a subclass can use the constructors of its superclass by using the super keyword.

The following code describes how constructor overloading works:

  • Share/Bookmark

What is the Locale class?

The Locale class is used to provide a number of convenient constants that are used to create Locale objects for commonly used locales. It is a mechanism for identifying objects, not a container for the objects themselves. The Locale class is used to represent an object that describes a geographical, cultural, or political region. This class is particularly useful for internationalization. Each region has different formats to present the date, time, and numbers. The Locale class is used to present these formats. The Locale class has the following constructors:

  • Locale(String language)
    This constructor builds a locale object to represent a language specific to a region.

  • Share/Bookmark