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 trialPeter Kurkowski
595 PointsI dont understand what this question is asking me to do regarding formatted string.
My Code:
String response; boolean noResponse; do { response = console.readLine("Do you understand do while loops?"); noResponse = (response.equalsIgnoreCase("no")); if (noResponse) { console.printf("Try again."); } } while (noResponse); String closing = console.printf("Because you said %s, you passed the test!");
The question is asking for me to enter a formatted string that includes the console.readLine value entered for response. I'm confused how i would create another string that includes the value entered for a previously declared string.
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
boolean noResponse;
do {
response = console.readLine("Do you understand do while loops?");
noResponse = (response.equalsIgnoreCase("no"));
if (noResponse) {
console.printf("Try again.");
}
} while (noResponse);
String closing = console.printf("Because you said %s, you passed the test!");
2 Answers
Peter Kurkowski
595 PointsI solved the problem myself by looking back at old code:
console.printf("Because you said %s, you passed the test!",response);
but i hate doing that, it feels like cheating.
Peter Kurkowski
595 PointsI just feel like its cheating when ive followed the video examples, written out the code he has then i go and just copy it in the exercises. i feel like that doesnt help me fully grasp the concepts. is this something i should not worry about?
Chris Freeman
Treehouse Moderator 68,441 PointsIn short, don't worry about it. It's hard to remember all of the methods and their signatures at first. After more experience looking at lots of code it becomes second nature to construct the statements correctly. Manually repeating proper code is the first step. Using the lessons to synthesize new code come next. Then finally coding from a blank slate.
Peter Kurkowski
595 PointsThanks for the help! Really appreciated.
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsWay to go! Everyone looks at old code so don't worry about it. I like to keep snippets of code and other notes for reference.
Peter Kurkowski
595 PointsPeter Kurkowski
595 PointsI just feel like its cheating when ive followed the video examples, written out the code he has then i go and just copy it in the exercises. i feel like that doesnt help me fully grasp the concepts. is this something i should not worry about?