Java Java Basics Getting Started with Java Strings, Variables, and Formatting

what is the error on line 3?

// I have setup a object for you named console
String firstName="Devin Ray";
console.printf("Devin Ray");
Vidhur Savyasachin
Vidhur Savyasachin
6,678 Points

String firstName = "Devin Ray"; console.printf("%s is my First name",firstName);

This should work.

I tried this and it didnt work

1 Answer

Edit. Revisiting this today (25/01/2019) and it looks like the challenge has changed. Or maybe I just checked part 1 with the other given answer. I'm not sure what happened.

My initial answer (Hi Devin. Vidhur Savyasachin 's answer is correct. It will work,) actually was not quite right.

Anyway, Devin Ray, if you're still struggling:

  • Part 1 : create a String variable that stores your name - You did that perfectly in line 2 (line 1 is the comments in grey)
  • Part 2: call the printf method on the console to make it write "<YOUR NAME> can code in Java!" - That's your line 3. You did great but the message to write is incomplete. You need to add "can code in Java!" to your name.
  • Part 3: you need to format the message, replacing your name with %s and adding firstName (the variable that stores your name) after the message String.

Hope that helps :)