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

Tomas Verblya
Tomas Verblya
1,998 Points

console.prinf("anything"); doesn't work. says it cannot find symbol?

I am trying to call the prinf command on the object console. But for some reason it doesn't work, not even a simple string is being called. Perhaps the console object is broken or something? The task says to call the prinf method on the console object.

Name.java
String firstName = "Tomas";
console.prinf("%s can code in Java!\n", firstName);

3 Answers

Hi, Tomas Verblya It can't find the symbol because it can't see the part where the name variable is in the printf statement. there needs to be a comma in after the String Formatter :) . You can see it as a distinction of the rest of the string.

andren
andren
28,558 Points

Actually It can't find the symbol because he has a typo in the method name, the arguments he is passing in his solution attempt is actually completely fine. There is a comma between the formatted string and the variable he is inserting which is all that is needed in this case. You don't need to have any commas within the formatted string itself.

andren
andren
28,558 Points

The method is called printf (print formatted) not prinf. The typo in the name is what causes you to get an error message.

Tomas Verblya
Tomas Verblya
1,998 Points

I found it myself, but it took me 25 minutes to find the typo. I tried retyping it many many times. Oh lord. I guess these type of typoes and mistakes will be a commong occurance. Thank you all!

andren
andren
28,558 Points

Yeah minor typos like this is indeed common when you are just starting out. It should be noted though that when Java states that it cannot find a symbol that usually means that you misspelled something so it's a good hint they you should carefully examine and double check the code on the line it is complaining about. In larger challenges it can be extremely difficult to figure out where you have made a typo without the help of the comilers error messages. So it's something with keeping in mind.

Compiler error messages are often more helpful than people give them credit for. If you try your best to understand them and use the fact that it points to the line where it encountered an error to your advantage, then you will be able to fix a lot of errors pretty quickly compared to if you tried to find the issue by examining all of your code manually.