• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Program for Console  RSS feed

 
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?
 
Sheriff
Posts: 5961
905
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
Sheriff
Posts: 5961
905
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
 
Bartender
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.
 
Sheriff
Posts: 9613
37
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
Bartender
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!