Solved

JDK6: Console

Posted on 2011-02-19
2
316 Views
Last Modified: 2012-05-11
hi all,

i have a problem by using method console(). It could not be compiled.

following are the codes.

can someone tell me where is the problem?

thanks,
wantime
import java.io.*
public class Test{
 public static void main(String[] args){
   Console c = new Console();
 }
}

Open in new window

0
Comment
Question by:wantime
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 500 total points
ID: 34933427
http://www.stupidjavatricks.com/?p=43
Console does not have public constructors - youshoud get it from System, see above link
0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 34933501
You just say:

Console c = System.console();

instead  of  Console c = new Console();

It is probably also worth reading what they write there in the article above
about different cases when you can obtain Console and when it will return null.

More or less the same stuff in a more standard site with Java 6 API
http://download.oracle.com/javase/6/docs/api/java/io/Console.html
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question