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

Ezekiel dela Peña
Ezekiel dela Peña
6,231 Points

Question about Java here and Java in Eclipse/Netbeans

Is System.out.print(""); &&
Console console = System.console();

console.printf("");

the same?

2 Answers

Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

Hey Ezekiel,

Hey Ezekiel, System.out.printf() is a valid method to call on System, and is very similar to Console.printf()

Console's can be kind of difficult to set up in an IDE like Netbeans or Eclipse, because it sees the value as null as always there are workarounds to make it work, but it's more work, and we want to get the same result for the least amount of work, so generally you use the System.out.printf()

Which works perfectly fine.

Thanks, let me know if this helps.

No, they're not.

String hello = "Hello";
System.out.printf(hello + " World!");

would be the same as:

Console console = System.console();
String hello = "Hello";
console.printf("%s World!", hello);

so you can't use %s in System.out.