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 trialSirisha Aluru
4,406 Pointsworks in workspace , but compilier errors in Challenge task
This is what I get when I check work JavaTester.java:73: error: illegal start of expression import java.io.Console; ^ JavaTester.java:73: error: not a statement import java.io.Console; ^ JavaTester.java:74: error: illegal start of expression public class Name { ^ 3 errors
// I have setup a java.io.Console object for you named console
import java.io.Console;
public class Name {
public static void main(String [] args) {
Console console =System.console();
String firstname="Sirisha";
}
}
1 Answer
Steven Parker
231,184 PointsThe challenge tasks are not just about writing code that runs, it must also satisfy the requirements given in the instructions. This particular challenge is very simple and requires only 2 lines of code — your code may run but it's way fancier than needed. Other specific issues that will cause the challenge to not pass:
- using variable names different from what the instructions ask for
- creating output that is different from (or more than) what the challenge expects
- changing literal strings that are given to you to use by the instructions
- creating extra program structures (classes, methods, loops, conditionals, etc.) that are not asked for
Sirisha Aluru
4,406 PointsThank you for your reply, it was my first challenge and was not clear about the requirements.
Sirisha Aluru
4,406 PointsSirisha Aluru
4,406 PointsActually this is what I have in workspace that is working
import java.io.Console; public class Name {
public static void main(String [] args) { Console console =System.console(); String firstname="Sirisha"; console.printf (" Hello , my name is %s\n", firstname); console.printf(" %s is learning how to write java\n", firstname); } }