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

i have no idea what i'm doing wrong in this step

i tried both printf("my name"); and console.printf ("myname");

Name.java
// I have setup a java.io.Console object for you named console.
String firstName = "abdu";
console printf("my name is abdu");

2 Answers

Hey there! Since it seems you're fairly new to the course, welcome to the fun! You were making several mistakes in this challenge but they're common and easy to fix so don't worry!

You declared the variable properly but the challenge is asking you to use the printf() method which is meant to print a formatted string to the console. The way you would properly call this method and format your string would be as seen below:

String firstName = "Brennen";
System.out.printf("%s can code in Java!", firstName);

Hope this helps you out, and good luck on your java journey!

Manish Giri
Manish Giri
16,266 Points

A couple of issues -

  1. You shouldn't have a space between console and printf - console printf("my name is abdu");. printf is a method that needs to be called on the console object, so it should be console.printf("...");
  2. You need to use the firstName variable in the print statement, instead of putting in your firstname directly, so, it should be - console.printf("%s can code in Java!", firstName)