Computer Science Canada Illegal Start of Type Error in Java Program |
Author: | Varsteil [ Thu Nov 01, 2012 9:41 am ] | ||
Post subject: | Illegal Start of Type Error in Java Program | ||
I'm new to Java programming and I was making a program to calculate Imperial and Metric conversions, however, I'm encountering 3 errors in my code; illegal start of type, identifier expected, and orphaned case. I'd appreciate it if anyone could tell me how to fix it.
|
Author: | DemonWasp [ Thu Nov 01, 2012 9:49 am ] |
Post subject: | RE:Illegal Start of Type Error in Java Program |
Your switch is outside your main(){} method. Put it inside the main() method. It would be easier to read your code (and find this type of problem) if you indent correctly. |
Author: | Varsteil [ Thu Nov 01, 2012 2:46 pm ] |
Post subject: | Re: Illegal Start of Type Error in Java Program |
Thanks, it fixed my error but now I'm getting a bunch of "Cannot make a static reference to the non-static field number" errors I think it means that it can't make a reference to my variables, but how do I fix it? I'm not going to post the code again because there's a lot of errors but every line that has a variable in it gets this error. |
Author: | Insectoid [ Thu Nov 01, 2012 6:10 pm ] |
Post subject: | RE:Illegal Start of Type Error in Java Program |
number and choice should be declared as static ints. |
Author: | Varsteil [ Fri Nov 02, 2012 9:26 am ] |
Post subject: | Re: Illegal Start of Type Error in Java Program |
Thanks, that fixed it |