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,084 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 ARGHANDABI20,998 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?