Answer the question
In order to leave comments, you need to log in
Why does it return zero year if set is used?
public class NewCalendar {
private int year;
public int getYear(){
return year;
}
public void setYear(int y){
year = y;
}
int year(){
for(year=2021; year < 2070; year++) {
System.out.println(" " + year);
// Подгон февраля под високосный год
if (year % 4 == 0) {
/*days[1] = 28*/
System.out.println("Високосный год ");
}
else {
System.out.println("Не високосный год ");
}
//days[1] = 29; // Високосный
//return 0;
}
//} return year;
return 0;
}
}
//}
public class NewCalendarTest {
public static void main(String[] args) {
NewCalendar nc = new NewCalendar();
nc.setYear(2021);
System.out.println(" " + nc.year());
}
}
Answer the question
In order to leave comments, you need to log in
Because year() returns 0(return 0;). You need to use getYear()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question