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 trialbranden newman
Courses Plus Student 653 PointsError messages when compiling
Hello everybody, well I am not sure where the mistake is so any help pointing it out would be appreciated. The only bit I wrote was the second console.printf on line 9 that's it no adding or deleting of anything else.
import java.io.Console;
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
// Welcome to the Introductions program! Your code goes below here
console.printf("Hello, my name is Branden");
} console.printf("Branden is learning how to write Java");
}
the error messages
treehouse:~/workspace$ javac Introductions.java
Introductions.java:9: error: <identifier> expected
} console.printf("Branden is learning how to write Java");
^
Introductions.java:9: error: illegal start of type
} console.printf("Branden is learning how to write Java");
^
2 errors
treehouse:~/workspace
Thanks again for any help provided
4 Answers
Kourosh Raeen
23,733 PointsYour second console.printf is outside the main() method. Just move it above the closing }.
branden newman
Courses Plus Student 653 PointsThanks for responding but to be honest I do not understand what you mean. Sorry if I am being a bit of a dense newb here but can I get an example of what I need to do?
Kourosh Raeen
23,733 PointsThe method main() has an opening brace and a closing one and your second printf statement has to be within { and }. So it should look like this:
import java.io.Console;
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
// Welcome to the Introductions program! Your code goes below here
console.printf("Hello, my name is Branden");
console.printf("Branden is learning how to write Java");
}
}
branden newman
Courses Plus Student 653 PointsThank you so much Kourosh! =) question answered.