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 trialNikola Vichev
1,668 PointsHi, guys, I keep getting this error and I just can't figure it out, help, please
import java.io.Console;
public class Main {
public static void main(String[] args) { Console console = System.console();
Cow cow = new Cow("Larry");
System.out.printf("The cow's name is %s,
cow.getCowName());
} }
Main.java:11: error: illegal start of expression
cow.getCowName());
^
Main.java:11: error: ';' expected
cow.getCowName());
2 Answers
Steven Parker
231,271 PointsThere's a few issues:
- in Main.java line 10, the string is missing the ending quote mark
- Main.java line 11 calls "getCowName" but the method in Cow.java is just "getName"
- in Cow.java line 11 the constructor is private instead of public
Nikola Vichev
1,668 PointsThanks a lot, Steven. I still don't quite get everything, but I'll keep pushing. At least I got it working with your help
Nikola Vichev
1,668 PointsThanks a lot, Steven. Here's the link https://w.trhou.se/oij293f1q6
Steven Parker
231,271 PointsSteven Parker
231,271 PointsTo allow your issue to be replicated, make a snapshot of your workspace and post the link to it here.