Skip to main content

Why so many errors?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
Anonymous

I am trying to learn Java since a few days back. Now I think I have learnt a little but the compiler seems to think differently... In the code below it gives me no less than 11 errors, and I can't find a single one.

public class YourSchedule
{
public static void main( String[] args )
{
String course1, course2, course3, teacher1, teacher2, teacher3;

course1 = "English";
course2 = "Math";
course3 = "Swedish";
teacher1 = "X";
teacher2 = "Y";
teacher3 = "Z";

System.out.println( "+-------------------------------------+");
System.out.println( "1 "+course1+" | "+teacher1+");
System.out.println( "1 "+course2+" | "+teacher2+");
System.out.println( "1 "+course3+" | "+teacher3+");

}
}

The errors given are : unclosed string literal (3 errors), ';' expected (5 errors), illegal start of expression (2 errors) and Reached end of file without parsing (1). I have looked up the meanings for all of these and I still can't find any problems. All of the error messages seem to be totally off the mark. What am I missing??

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
HermitCrab

Okay... Typically, as I posted the question I just found the error myself - three missing " after the teachers. But why then does it show error messages for a bunch of other things that have nothing to do with the real errors? It doesn't make any sense...