Currently, I am trying to make a couple of methods access each other. However, I am getting an error that I have not been able to figure out.
This is the error I get:
Cannot make a static reference to the non-static method acceptadd(String) from the type teaminfo
I looked to see if a method or a variable was static when it was not supposed to be, but neither the method acceptadd(String) or the method I am calling it from is static. I have no idea on how to fix it on this point, can someone help me?
Here’s my code for GuiAddReject:
The error Cannot make a static reference to the non-static method acceptadd(String) from the type teaminfo is at this line:
teaminfo.acceptadd(playername);
Here is teaminfo.java:
Any help would be appreciated.
Also, sorry about the links, couldn’t get the code brackets to work…
The error means that you are trying to access a non-static method (
acceptadd) from a static context (i.e. not from an object). To solve this you need to make an object of the class to which the method you want to call belongs and call the method from its reference.for example the correct way would be: