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

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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 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!