Cannot make a static reference to the non-static method login() from the type yGym
时间: 2023-10-28 17:24:10 浏览: 92
广告图片(类似淘宝图片)
This error message indicates that you are trying to call a non-static method from a static context. In Java, non-static methods belong to an instance of a class, whereas static methods belong to the class itself.
To resolve this error, you need to either make the method static or create an instance of the class and call the method on that instance.
If you want to make the method static, you can add the "static" keyword to the method signature. For example:
```java
public static void login() {
// method implementation
}
```
Alternatively, if you want to call a non-static method, you need to first create an instance of the class and then call the method on that instance. For example:
```java
yGym gym = new yGym();
gym.login();
```
I hope this helps to resolve your error!
阅读全文