package exercise2; import java.util.Scanner; public class Exercise2 { Scanner user_input = new Scanner(System.in); public static void main(String[] args) { System.out.println ("Pick a number from 0 to 100"); String number = user_input.next(); int pn =Integer.parseInt(number.trim()); } }
I keep getting this error on the "String number = user_input.next();" line.
non-static variable user_input cannot be referenced from a static context
Any help? I've looked online and I get lots of help for assigning variables, but not with user input.