what is constructor
this is one of special method of any class in java
it's name will same to class name

like this-------

class Demo      ------------this is class name
{
Demo       ------------this is constrator name
{

}
}

mainly we use it for initialise variables
it can be parameterized
and it can be default

It make automatic called when we maked object of any class
when we do not maked it then java will maked it autometic

No comments:

Post a Comment

programme for armstrong number for 3 digit in java

armstrong number import java.util.Scanner; class Mittu {     public static void main(String []args)     {         Scanner s=new Sca...