-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGettersDate.java
More file actions
34 lines (30 loc) · 807 Bytes
/
Copy pathGettersDate.java
File metadata and controls
34 lines (30 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class UsingGetters{
private int day = 24;
private String month = "September";
private int year = 2019;
public void setDay(int day){
this.day = day;
}
public int getDay(){
return day;
}
public void setMonth(String month){
this.month = month;
}
public String getMonth(){
return month;
}
public void setYear(int year){
this.year = year;
}
public int getYear(){
return year;
}
}
class GettersDate{
public static void main(String[] args){
UsingGetters now = new UsingGetters();
System.out.println("The current month is " + now.getMonth() + ".");
System.out.println("In fact, it is " + now.getMonth() + " " + now.getDay() + ", " + now.getYear() + ".");
}
}