S
S
Sergey Sergey2021-05-10 22:54:42
Java
Sergey Sergey, 2021-05-10 22:54:42

Seters and geters are created through the void method, then there will be no return?

private int year;
     void setYear(){
         }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2021-05-10
@Sergei1111

The essence of the getter is that there is a return and, accordingly, void does not fit the
pivate int year;
getter

public int getYear(){
return year;
}

setter
public void setYear(int year) {
this.year = year;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question