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 Strings, Variables, and Formatting

Call the printf method on the console object and make it write out "<YOUR NAME> can code in Java!" I do not understand

I have not been able to grasp they way it should be written in the console. for example do I need to type public class console and public void main to use printf?

Name.java
// I have setup a java.io.Console object for you named console
public class console{
  plubic static main (string [] args)
  Console console=system.console();
String firstName = "Chris" ;
Console. printf("%s",firstName);
}

3 Answers

Vedang Patel
Vedang Patel
7,114 Points

Hi Chris

You've done many mistakes let me point them out

  1. you don't have to write the first 3 lines and the last line.

  2. You shouldn't keep a space between console. and printf

  3. after %s you should type "can code in Java!"

If you can't find it out go below

copy it if you like!

SPOILER ALERT

String firstName = "Vedang" ;
console.printf("%s can code in Java!", firstName);

Nope that did not work Vedang Patel

String firstName="Chris"; Console.printf("%s can code in Java!", firstName);

and resulted in

JavaTester.java:74: error: cannot find symbol Console.printf("%s can code in Java!", firstName); ^ symbol: variable Console location: class JavaTester Note: JavaTester.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 1 error

Vedang Patel
Vedang Patel
7,114 Points

your Console has a capital C, it should Lower Case. As you have to remember Java is a case sensitive language

thanks for the help