Strange autogenerated getter and setter in eclipse

前端 未结 3 1388
慢半拍i
慢半拍i 2021-01-18 18:35

When I use the auto generation for getter/setter in Eclipse for an class field with a name like
String lAttr it will produce this:

public St         


        
相关标签:
3条回答
  • 2021-01-18 18:46

    What version of Eclipse are you using? I tried this in Eclipse 3.5.2, and when I moused-over the field and clicked "create getter and setter for 'lAttr'", the dialog box that appeared allowed me to change the generated names, in this case from getlAttr to getLAttr and setlAttr to setLAttr. Another option would be to just name your field LAttr from the start and avoid the whole mess.

    0 讨论(0)
  • 2021-01-18 18:54

    It is possible to give your own names of getter/setter in eclipse. Make your variable private. Go to error where you are trying to access private variable in another class. Select the quick fix of generating getter/setter. It pops up a dialog where getter/setter names are modifiable.

    0 讨论(0)
  • 2021-01-18 19:07

    1) I don't think it's possible, similar discussion:

    Change Eclipse Getters Setters syntax

    2) another option, as alternative, is to use templates for getters and setters. though there is a small problem there too, similar discussion:

    How to deal with Camel Case for Eclipse Templates?

    0 讨论(0)
提交回复
热议问题