constructor

Code Example - constructor

                
                        public class ConsDemo {
   public static void main(String args[]) {
      MyClass t1 = new MyClass();
      MyClass t2 = new MyClass();
      System.out.println(t1.num + " " + t2.num);
   }
}
                    
                
 

constructor definition

                        
                                Constructor are a type of method 
* Share the name of class
* Called when you Instantiate a Class

Default Constructor accepts no Arguments
                            
                        
 

Related code examples