Constructor overloading issue in java -


i learing core java , practicing it. understand concept of method overloading. when run below program shows error "

constructor methodover in class methodover cannot applied given types;         methodover m2 = new methodover();                         ^   required: int,int   found: no arguments   reason: actual , formal argument lists differ in length" 

please find code below , help.. learning.

public class methodover {        int x;     int y;       methodover(int a, int b)     {         x=a;         y=b;         system.out.println("the values assigned are" +x+ "and" +y);      }      void multiply(methodover obj)     {   obj.x = 2;         obj.y = 2;         system.out.println("the multiplication result object passed is" +obj.x*obj.y );      }     public static void main(string[] args)     {         methodover m1 = new methodover(5,6);         methodover m2 = new methodover();         m2.multiply(m1);      }  } 

while playing constructor, use default constructor avoid run time exceptions.define default constructor in code..

 methodover()  {       //initialize default values.       this(0, 0);  }  

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -