L
L
Leonid Bylin2018-10-18 14:01:27
Java
Leonid Bylin, 2018-10-18 14:01:27

Error: Error:(4, 9) java: non-static variable e cannot be referenced from a static context?

error code : Error:(4, 9) java: non-static variable e cannot be referenced from a static context?
here is the class code:

public class jfx {
    int e;
    public static void main(String[] args) {
        e=54;
    }
}

I didn’t understand why the error occurred (it didn’t happen before !!!) because until that moment I could safely use variables from the class field

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EVGENY T., 2018-10-18
@Nel_Bylin

You are trying to use a non-static variable from a static method - you can't do that. Declare static int e - will help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question