Two methods of automatically generating constructors in eclipse

How to automatically generate constructors in eclipse eclipse is a very good ide. I feel that the development efficiency is very high when I use eclipse when writing Java programs. And there are many shortcuts and simple ways for you to use, and you can directly generate class files (without javac compilation). Today, let's introduce how to generate a class constructor.

Method 1:

I created a class with two private attributes, age and name. Now construct two constructors, one with no parameters and one with parameters. Right click - > source - > generate constructors from superclass to create a constructor with null parameters; Right click - > source - > generate constructors using fields to create a constructor with parameters.

Method 2: directly up shift + Alt + s, and then select generate constructors from superclass or generate constructors using fields to construct empty and parameterized constructors respectively.

The above two methods of automatically generating constructors in eclipse are all the contents shared by Xiaobian. I hope to give you a reference and support more programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>