Joseph Saika2,539 Points
guys can someone correct the above code for me .i'm trying all the suggestions given but its not working
guys can someone correct the above code for me . i'm trying all the suggestions given its not working
Jonathan GrieveTreehouse Moderator 81,659 Points
Okay, let's try again this time going step by step. :-)
In your post over on this thread (https://teamtreehouse.com/community/how-do-i-write-expressions-using-a-string-formatter) You successfully defined a String variable which we will later pass in to the printf() method in the next 2 tasks,
Now part 2 tells us to write a string of text in the java console that contains a given sentence.
printf() It will say something like this "<YOUR NAME> can code in Java!". You can write your own name into this sentence for now, the challenge should accept it. What's important at this stage is you write something to the console
String firstName="joseph"; System.out.printf("Jonnie can code in Java!");
The final task is about getting practice with format specifiers and it uses the variable we defined in task 1. That's why the sentence said <YOUR NAME> because it's intended to be replaced with the value of
firstName. To do this you use a format specifier like
%s. You then pass in the name of the variable as an argument like this.
String firstName="joseph"; System.out.printf("%s can code in Java!", firstName);
Hopefully, this will help you see how format specifiers are used in Java to display the values of variables! :-)