Java Error: The constructor is undefined

前端 未结 9 1210
庸人自扰
庸人自扰 2020-11-29 13:31

In Java, Why am I getting this error:

Error: The constructor WeightIn() is undefined

Java Code:

public class WeightIn{
  pr         


        
相关标签:
9条回答
  • 2020-11-29 14:01
    WeightIn weight1 = new WeightIn();  
    

    The default constructor is not defined. Please define it like this:-

    public weightIn()
        {
        }
    
    0 讨论(0)
  • 2020-11-29 14:08

    Add this to your class:

    public WeightIn(){
    }
    
    • Please understand that default no-argument constructor is provided only if no other constructor is written
    • If you write any constructor, then compiler does not provided default no-arg constructor. You have to specify one.
    0 讨论(0)
  • 2020-11-29 14:08

    You do not have the constructor WeightIn() .Create it or give parameters in main method to constructor.

    0 讨论(0)
提交回复
热议问题