• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Program for Console

 
Sonali Sehgal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am preparing for SCJP 6.
Can you please explain java.io.Console class with the help of small program?
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4519
281
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are only few methods in java.io.Console class
I would recommend you to read the javadoc (please have a look at the above link). And then you should solve some mock exam questions too.
 
Sonali Sehgal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried doing a program and there is a error coming in can you please help??

 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4519
281
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sonali Sehgal wrote:I tried doing a program and there is a error coming


What is the error you are getting there?
I can see a little error that the "name" variable is not defined.
 
Sonali Sehgal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Devaka I got the solution and another thing I was using the version of Java that is 1.5 to fix the problem it should be of version1.6
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that netbeans does not support the console class internally.
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you call System.console(), it will only return an instance of Console class if one is available. If the program is running in an environment which doesn't have a console, then null is returned...
 
Sonali Sehgal
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wouter and Ankit,


So in order to execute the program will the upgrading the version of java from 1.5 to 1.6 will help or only console needs to be added to netbeans ....As Kathy says java.io.Console is the latest in version 1.6....I also tried this program on another computer with version 1.6 java it was successfully executing........
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to use java.io.Console you need to hava java 1.6. The problem is that if you develop in netbeans, the console class will not be available because netbeans does (not yet) support it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic