Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Basics Getting Started with Java Introduction to Your Tools

I'm using bluej as my work space. why wont bluej work with console.printf method?

help

Carlos Federico Puebla Larregle
Carlos Federico Puebla Larregle
21,074 Points

Are you importing the "java.io.Console;" and making an instance of that class? like:

Console console = System.console();

So that you can use the variable "console" to print in a formatted way, if not that may be the problem.

I hope that helps you a little bit.

I imported and created everything necessary. Still no luck.

1 Answer

For BlueJ IDE, instead of "console.printf()", you can use "System.out.printf()" or "System.out.println()".

In my opinion those are much easier and have fewer problems than using a Console object.

Yea. But what can I do in stead of console.readLine().

Also: WHY is console not working in bluej?

You didn't post any source code, so it is impossible for us to see what you are doing wrong.

Another way to get input from the console is the use a Reader:

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class MyClass {
  ...
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String input = br.readLine();
  System.out.println("You typed into the console: " + input);
  ...
}