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 trial

Java Java Basics Using your New Tools Multiple Strings

Yash Joshi
Yash Joshi
609 Points

I cannot compile my code:

TreeStory.java:28: error: variable name is already defined in method main(String[])
String name = console.readLine("Enter a name: ");
^
TreeStory.java:29: error: variable adjective is already defined in method main(String[])
String adjective = console.readLine("Enter an adjective: ");
^
2 errors

It shows me this even though I'm pretty sure I followed the video properly.. please help! (Multiple String, Java Basics Course, Android Development Track)

3 Answers

Yash Joshi
Yash Joshi
609 Points

Wait never mind I got it to work! Thanks anyway guys!

Hi Yash,

I've done the first couple of tasks in this challenge, and they seem to be the ones causing the problem. If not, please post your code; the errors are only so helpful.

// I've imported java.io.Console for you.  It is stored in a variable called console for you.
String name = console.readLine("Enter your name: ");
String pastTenseVerb = console.readLine("Enter a past tense verb: ");

I think you may have lost your way a little as it seems you're asking for adjective as a variable name. Show us your code; we can help!

Steve.

Yash Joshi
Yash Joshi
609 Points

Thanks Steve! I got it right after I posted the question on the forum but thanks for your help anyway!