What are the shortcut to Auto-generating toString Method in Eclipse?

后端 未结 9 1300
遥遥无期
遥遥无期 2020-12-03 13:17

Is it good or bad practice auto-generating toString methods for some simple classes?

I was thinking of generating something like below where it takes th

9条回答
  •  死守一世寂寞
    2020-12-03 13:54

    Just noticed -In NetBeans IDE you can generate toString() method by selecting fields you want to generate it for right click->insert code or use shortcut ALT+INSERT and then select toString().

    Way it looks is :

    @Override
    public String toString() {
        return "ClassName{"+"fieldName="+fieldName+'}';
    }
    

    Its great way to debug and no need for additional libs.

提交回复
热议问题