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 trialSolomon Kelley
2,310 Pointsdata type declaration?
it seems to be missing a data type declaration but i have no idea what that is...
String firstName = ("Gordon");
String lastName = ("Sumner");
console.printf("Hello %s", firstName);
console.readLine("Which band? ", band);
1 Answer
Steve Hunter
57,712 PointsHi Solomon,
Your last line isn't quite right.
You want to declare a new String object which is being read from user input.
String firstName = "Gordon";
String lastName = "Sumner";
console.printf("Hello %s", firstName);
String band = console.readLine("Which band? ");
Without defining band
as a String
your code lacks a data type. The last line uses readLine
which is a way of getting user input. So it is asking the user which band (The Police) and invites them to type the answer. That answer is then stored in the band
variable. As you haven't declared that yet, you need to tell the compiler that it is a String. Make sense?
I hope that helps,
Steve.