I am writing this simple code but I have an error at last line:
"Cannot make a static reference to the non-static field br"
Kindly explain me why I have this error. I can suppress the error if I make the variable static, like static BufferedReader br
or if I declare it inside the main method.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Object;
public class Solution {
BufferedReader br;
public static void main(String[] args) {
br = new BufferedReader(new InputStreamReader(System.in));
}
}