Why do I need to write a constructor here explicitly?

前端 未结 7 2064
無奈伤痛
無奈伤痛 2021-01-15 11:28

This is how I encountered the problem. I am giving an example:

package check;

public class Check {
  int a,b;
  Check (int i,int j) {
    a = i;
    b = j;
         


        
7条回答
  •  我在风中等你
    2021-01-15 11:50

    Think that it's not warning you and you write a piece of code like:

    V v = new V();
    

    Then, what would you expect your compiler to behave? I mean, there is no no-arg consructor defined. You need to explicity add it.

    Check() {
    
    }
    

提交回复
热议问题