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
Danielle Hubbard
3,076 PointsError: non-static method printf - I've checked my work several times but can't seem to figure it out.
Here is my Java Script:
String name = console.readLine("Enter your name: ");
String adjective = console.readLine("Enter an adjective: ");
Console.printf("%s is very %s", name, adjective);
When I try to compile I get this error:
TreeStory.java:15: error: non-static method printf(String,Object...) cannot be referenced from a static context Console.printf("%s is very %s", name, adjective);
Anthony Babich
5,505 PointsHi,
After searching google and cross referencing a few other posts the problem might be that you're capitalizing Console.print, try lower case console.printf. Good luck!
2 Answers
Christopher Augg
21,223 PointsDanielle,
You should use console with a lowercase c :
console.printf("%s is very %s", name, adjective);
Regards,
Chris
ALI RAZA
183 Pointsgreat work chris
Christopher Augg
21,223 PointsChristopher Augg
21,223 PointsDanielle,
I edited the format of your post to display your code more clearly. Please refer to Markdown Cheatsheet to see how to do this if you would like to post code like this in the future. It definitely helps others when reading your posts.
Regards,
Chris