9 Star 23 Fork 2

tzhanggit/JavaProgramming

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
TestBD.java 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
tzhanggit 提交于 2020-03-19 14:23 +08:00 . 修改部分代码注释
package ch4;
class BirthDate {
int day;
int month;
int year;
public BirthDate(int d, int m, int y) {
day = d;
month = m;
year = y;
}
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public void display() {
System.out.println("Birthdate is year: " + year + ", month: " + month + ", day: " + day);
}
}
public class TestBD {
public void change1(int i) {
i = 12345;
}
public void change2(BirthDate b) {
b = new BirthDate(3, 17, 2020);
}
public void change3(BirthDate b) {
b.setDay(19);
}
public static void main(String[] args) {
TestBD test = new TestBD();
int date = 1;
BirthDate d1 = new BirthDate(1, 1, 2019);
BirthDate d2 = new BirthDate(3, 3, 2020);
test.change1(date);
test.change2(d1);
test.change3(d2);
System.out.println("date=" + date);
d1.display();
d2.display();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/tzhanggit/JavaProgramming.git
git@gitee.com:tzhanggit/JavaProgramming.git
tzhanggit
JavaProgramming
JavaProgramming
master

搜索帮助