Solved

JDK6: Console

Posted on 2011-02-19
2
280 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
  • 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countAbc challenge 9 49
JDeveloper 12c for 32 bit 4 35
eclipse formatting 6 41
VB Script to add site to Java Exception List 4 13
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

706 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now