Java – how to name getters / setters in Android projects

topic

Suppose there is a public class named private int_ Private variable with xtouchdown = 0;

What is the getter / setter name for this private variable?

One Get of getter_ Xtouchdown() and set of setters_ xTouchDown(). These are the default values selected by eclipse > Refactor > encapsulate field

Getxtouchdown() of getter and setxtouchdown() of setter

C. Xtouchdown() for getters and setxtouchdown() for setters

d. Others

Solution

I would say:

Getxtouchdown() of getter and setxtouchdown() of setter

Why?

It is subject to Java Naming Conventions and more importantly:

Getters and setters are suitable for the outside world Client code that uses your method should not care about the internal naming of your fields

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
分享
二维码
< <上一篇
下一篇>>