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 trialISAIAH S
1,409 PointsWhat is Wrong With My Code?
Here's my code:
import java.io.Console;
public class Isaiah {
public static void main(String[] args) {
Console console = System.console();
String questions = String number; &&
String mood; &&
String name; &&
String creature; &&
String color;
String number = console.readLine("Enter your favorite number: ");
String mood = console.readLine("Enter your favorite mood: ");
String name = console.readLine("Enter a name: ");
String creature = console.readLine("Enter your favorite creature: ");
String color = console.readLine("Enter your favorite color: ");
}
}
Thanks,
ISAIAH S
3 Answers
Henrik Hansen
23,176 PointsOk, I edited the previous answer... Format the questions string to fit your needs, then output it.
import java.io.Console;
public class Isaiah {
public static void main(String[] args) {
Console console = System.console();
String number = console.readLine("Enter your favorite number: ");
String mood = console.readLine("Enter your favorite mood: ");
String name = console.readLine("Enter a name: ");
String creature = console.readLine("Enter your favorite creature: ");
String color = console.readLine("Enter your favorite color: ");
String questions = number + mood + name + creature + color;
}
}
ISAIAH S
1,409 PointsStill didn't work. Here's my Error:
Isaiah.java:11: error: not a statement String creature; && ^ Isaiah.java:11: error: illegal start of expression String creature; && ^ Isaiah.java:12: error: ';' expected String color; ^ Isaiah.java:12: error: not a statement String color; ^ 14 errors treehouse:~/workspace$
Henrik Hansen
23,176 PointsI edited my answer. You should not use '&&' when declaring your variables.