Java中有哪些语法糖

2025-04-28 13:52:47
推荐回答(1个)
回答1:

举个最常用的例子。
以前定义属性是这么干:
private int x;
public int getAge(){
return x;
}
public void setAge(int age){
this.x=age;
}
现在是public int Age{get;set}这么干。

作者:江山
链接:https://www.zhihu.com/question/23846890/answer/33792043
来源:知乎
著作权归作者所有,转载请联系作者获得授权。