I have a class named Media
which has a method named setLoanItem
:
public void setLoanItem(String loan) {
this.onloan = loan;
}
I am trying to call this method from a class named GUI
in the following way:
public void loanItem() {
Media.setLoanItem("Yes");
}
But I am getting the error
non-static method setLoanItem(java.lang.String) cannot be referenced from a static context
I am simply trying to change the variable onloan
in the Media
class to "Yes" from the GUI
class.
I have looked at other topics with the same error message but nothing is clicking!
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…