What does “this()” method mean?

后端 未结 8 2030
眼角桃花
眼角桃花 2020-12-13 03:33

I ran into this block of code, and there is this one line I don\'t quit understand the meaning or what it is doing.

public Digraph(In in) {
    this(in.readI         


        
8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 04:09

    Using this() as a function like that, essentially calls the Constructor of the class. This allows you to all the generic initializations in one constructor and have specializations in others. So in this piece of code for example, the call to this(in.readInt()) is calling the Digraph constructor that has one int argument.

提交回复
热议问题