Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Jacob Klug469 Points
System.out.printf(" It was %s but chris switched it to %s %n", before, dispenser.getCharacterName()); not working
when I write that its suppost to print out It was yoda chris switched it to dark vader. For me it says It was yoda but chris switched it to yoda. What did i do wrong this is my code. System.out.printf(" It was %s but chris switched it to %s %n", before, dispenser.getCharacterName());
Jason AndersTreehouse Moderator 145,431 Points
Without seeing all your code, it's really difficult to say why. I don't see the
before variable being set, but if you are getting the same name for the placeholders, then something is off with that variable and how it's being set. Review the video and double check all your code (the problem is not with the line you shared). If you are using Treehouse's Workspaces, you can share a snapshot of your Workspace.
Hope you get it figured out. :)
HIDAYATULLAH ARGHANDABI21,009 Points
hi when you are work in compiler like eclipse or intelja dont write printf write print or printLine instead. check about these key words from interenet
I had a similar question about the flip from printf to print and println
I have used print and println from System.out .... etc.
printf seems to work like c's call (where I would concatenate variables and literal strings, printf in Java looks more like C.
Could you explain reasoning? Has printf in Java been deprecated?