constructor in java

Let’s learn constructor in java. Constructor in java Constructor is a special method or block of code used to initialize an object. It executes automatically when you create an object. Example: class DemoClass { // constructor name is same as class name DemoClass() { …. } } // calls DemoClass() constructor DemoClass obj = new…

Read More Constructor in java