Scanner Error

Hey so despite a youtube video telling me what to do, when I try to run my scanner program, it won’t work.

Code:
image

Error:
MyProgram.java.8: error: non-static method next() cannot be referenced from a static context
String response = Scanner.next();
^

I think you may need to use the Scanner instance, input, instead of Scanner
so Scanner.next() should be input.next()

I usually see
public static void main(String[] args) {
in these.

1 Like

Thank you so much, it worked!

1 Like