Java Error: The constructor is undefined -
in java, why getting error:
error: constructor weightin() undefined
java code:
public class weightin{ private double weight; private double height; public weightin (double weightin, double heightin){ weight = weightin; height = heightin; } public void setweight(double weightin){ weight = weightin; } public void setheight(double heightin){ height = heightin; } } public class weightinapp{ public static void main (string [] args){ weightin weight1 = new weightin(); //error happens here. weight1.setweight(3.65); weight2.setheight(1.7); } }
i have constructor defined.
add class.
public weightin(){ }
- please understand default no-argument constructor provided if no other constructor written
- if write constructor, compiler not provided default no-arg constructor. have specify one.
Comments
Post a Comment