Hello, This is my first post. I am taking a java programming class, my first, and it goes good some days and really bad the others. So I am working on an assignment and I cant figure out the 1 error I have. Any help would be nice! Thanks. The error I am getting is:
Ch7Ex12.java:13: illegal start of expression
public static void main(String[] args) throws FileNotFoundException
^
1 error
My code is:
//Michael
//Chapter 7 Example 12 assignment
//Ch7Ex12.java
// This program calculates GPA for male and females.
import java.io.*;
import java.util.*;
public class Ch7Ex12
{
{
public static void main(String[] args) throws FileNotFoundException
{
IntClass female = new IntClass();
IntClass male = new IntClass();
DoubleClass femaleGPA = new DoubleClass();
DoubleClass maleGPA = new DoubleClass();
DoubleClass averageFemaleGPA = new DoubleClass();
DoubleClass averageMaleGPA = new DoubleClass();
The problem is down to an extra opening curly brace between the class declaration and the main method, and presumably there's and extra closing curly brace at the end of the file.
Ok I tried what you suggested and I get a new error now.
c:\solution\java>javac Ch7Ex12.java:98: reached end of file while parsing
This is the same kind of thing - your curly braces are not matched. The compiler fell off the end of your code looking for the closing brace.
Hint: when opening curly braces, always put in the closing brace at the same time, then code between them. This way they will always match up.
The sooner you start to code, the longer the program will take...
R. Carlson
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Hint: when opening curly braces, configure your IDE to put in the closing brace at the same time, then code between them. This way they will always match up.
Fixed.
------
If you are satisfied with the responses, add to the user's rep!
Yup - I guess there's no good reason not to use a decent IDE, and if you're going to use one, make use of its facilities.
The tools we use have a profound (and devious!) influence on our thinking habits, and, therefore, on our thinking abilities...
E. Dijkstra
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Bookmarks