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 trialJarod "Todd" Foreman
2,039 PointsJava Basics Question of the Day. Need Help Please. (pastTenseVerb variable)
I am tasked with creating a new variable to store a past tense verb like walked. I also must accept input from the console with the readLine method. In my code, my attempt looks like it is correct to me, but I am obviously confused, or missing something. Anyone, please let me know what I may be missing or show/guide me the in the ways of the force/java. Sorry, big fan of SW. This is my error:
JavaTester.java:147: error: variable pastTenseVerb might not have been initialized if (pastTenseVerb.equals("UNDEFINED")) { ^ 1 error
// I've imported java.io.Console for you. It is stored in a variable called console for you.
String pastTenseVerb;
String name;
name = console.readLine("Enter your name: ");
console.printf("%s is a great person.,name");
name = console.readLine("Please list an example of a past tense verb: \n(clues: i.e. walked, shewed, swallowed)");
console.printf("He made sure the children %s.,pastTenseVerb");
2 Answers
Fahad Mutair
10,359 Pointsin 3rd task he's asking you to put both strings and show them in 1 sentence
Output a sentence that takes both the name and past tense verb using a single statement.It should look like this: name really past tense verb this coding exercise.
String name= console.readLine("Enter your name: ");
String pastTenseVerb= console.readLine("Please list an example of a past tense verb: \n(clues: i.e. walked, shewed, swallowed)");
console.printf("%s really %s this coding exercise.", name ,pastTenseVerb );
Jarod "Todd" Foreman
2,039 PointsThank you for the assist. It is very much appreciated. Todd
Fahad Mutair
10,359 Pointsyou're welcome :)