I am trying to create an object of Console class, but could not succeed. I am getting this error “The constructor Console() is not visible”. I also could not find any constructor in the document. Can anybody explain this?
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.
Jon Skeet’s answer is correct: you should use
System.console()to get hold of the one instance ofConsole.The reason for this is that
Consoleis an implementation of the Singleton design pattern, which is used when the author of an API wants to ensure that one and only one instance of a class is ever created.