public class ConsoleReader {
static BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
public static String readString() throws Exception {
String name = reader.readLine();
return name;
}
public static int readInt() throws Exception {
int a= Integer.parseInt(reader.readLine());
return a;
}
public static void main(String[] args) {
}
}
what if i will created static BufferReader variable?
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Art
1 March 2020, 07:16
Objects should be created in the main.
Creating a static variable will make the other classes to be able to use it. Static means a variable for every class, if not declared as private etc.
0
Ashish RajAnand
2 March 2020, 05:03
thanks art but i'm not satisfy with answer.
I know whatever you said ,sorry my question is what wiil problem arrive in consoleReadertask
0