initialize object directly in java

前端 未结 10 1041
逝去的感伤
逝去的感伤 2020-12-08 04:26

Is that possible to initialize object directly as we can do with String class in java:

such as:

String str=\"something...\";

I wan

10条回答
  •  悲哀的现实
    2020-12-08 04:58

    There are two types of Constructors in java.

    1. Default constructor
    2. Parameterized constructor

    You should create a parameterized constructor to create your object.

提交回复
热议问题