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

Kirk Yale
Kirk Yale
2,194 Points

What am I mistyping: String firstName = "Kirk"; console.printf("%s can code Java!", firstName);

For some reason, this code keeps on reading as invalid. I am not sure what I am doing wrong: String firstName = "Kirk"; console.printf("%s can code Java!", firstName);

I also tried this: String firstName = "Kirk"; console.printf("Kirk can code Java!");

But I still get an error. Can someone tell me where I have made a mistake? Thanks!

Name.java
// I have setup a java.io.Console object for you named console
String firstName = "Kirk";
console.printf("%s can code Java!", firstName);

2 Answers

Tonnie Fanadez
Tonnie Fanadez
UX Design Techdegree Graduate 22,767 Points

Hi Kirk Yale

Tested your code and I can't believe the problem came about because you left out the word in inside the sentence 'Kirk can code in Java!'.

But that's where the problem is; otherwise, you're good, keep it up high.

See my code below:

String firstName = "Kirk";
//your code (omits "in")
console.printf("%s can code Java!", firstName);
//correct code(includes the word "in" between code and Java
console.printf("%s can code in Java", firstName);

Cheers man.....

Kirk Yale
Kirk Yale
2,194 Points

Thanks, Tonnie! Cheers!