我是Java新手.
任何人都可以解释getter和setter方法的作用吗?
我们必须使用getter setters方法以及它与普通方法的区别?
我看到一些编码只有setter方法所以这里为什么没有声明getters方法?
private String wheel;
/**
* @param wheel the wheel to set
*/
public void setWheel(String wheel) {
this.wheel = wheel;
}
public void rotate() {
System.out.println(wheel+"rotated");
}
Run Code Online (Sandbox Code Playgroud)考虑Calculator使用以下代码命名的类:
class Calc extends Calculator {
Calculator calculator; // [Style 1]
Calculator calculator = new Calculator(); // [Style 2]
}
Run Code Online (Sandbox Code Playgroud)
据我所知,没有分配内存[1],但在语句中创建[2]了一个新Calculator对象.
除此之外是否还有其他差异?
我可以使用在开放层地图上添加标记Openlayers.Layer.markers.但我不能用这个 OpenLayers.Feature.Vector吗?.任何人都可以帮助我..请...提前谢谢
此致,Boomiraj.P