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 don't know how to do it

I don't know how to do it

// I have setup a java.io.Console object for you named console
console.printf("my name is alaa")

1 Answer

Ken Alger
Ken Alger
Treehouse Teacher


Welcome to Treehouse!

You didn't mention which Task in the Challenge you are on, so let's walk through them, okay?

Task 1

*Define a string variable named firstName that stores your name. Set the value to your name. *

In Java the convention to define a String variable is: String someStringName = "Your String Value"

For this challenge then we would do:

String firstName = "Alaa";

Task 2

Call the printf function on the console object and make it print out "<YOUR NAME> can code in Java!"

The challenge checking engine tends to be picky, so we want to make sure our output is exactly as requested, following punctuation and capitalization. The convention here is console.printf("What you want printed to the screen"); Which would translate for this challenge to:

console.printf("Alaa can code in Java!");

Remember to not delete the code from Task 1.

Task 3

Now replace your name with the firstName variable using the string formatter.

This task requires the use of the string formatter, if you do not have a good grasp on this concept, I would encourage you to watch the video(s) again as it is a key concept for this course. As such, I will let you try to figure it out on your own, but post back if you are still stuck.

Happy coding,