I see many Java samples which use BufferedReader as a static member instead of instance member. Is it some best practice? and when should or shouldn’t I do it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I found that the cases in which BufferedReader should not be closed when it is used with System.in ; because in that case Java does not allow to re-open it. In this scenario, it makes sense to declare this property as static.