Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!