Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Software Development Software Development
Search Search
Search for:
Tech Support Guy > > >

java illegal part of expression


(!)

cianz182's Avatar
cianz182 cianz182 is offline
Junior Member with 2 posts.
THREAD STARTER
 
Join Date: Nov 2011
Experience: Beginner
02-Nov-2011, 11:29 AM #1
java illegal part of expression
Hi everyone,

I appear to have some trouble for my java program when trying to compile it comes up with "illegal start of expression"

here is some of my code any help would be appreciated thanks!!
the error is on line 55

46.public int getImp(int[] numb){
47.if(numb[1] == 1 && numb[0] ==0){
48.imp = 0;
49.}
50.else{
51.imp = 1;
52.return imp;
53.}
54.public int checkPred(int n){
55.if(n>=1 && n <= 10 && n/2 <= 5){
56.pred = 1;
57.}
58.else{
59.pred = 0;
60.}
61.return pred;
62. }
63.}

Last edited by cianz182; 02-Nov-2011 at 11:33 AM.. Reason: added more information
andythepandy's Avatar
andythepandy andythepandy is offline
Computer Specs
Member with 365 posts.
 
Join Date: Jul 2006
Location: England
Experience: Intermediate to Advanced
02-Nov-2011, 07:08 PM #2
Hi and welcome,

It would appear that you haven't closed your curly braces for the function getImp

Code:
public int getImp(int[] numb){
    if(numb[1] == 1 && numb[0] ==0){
        imp = 0;
    }
    else{
        imp = 1;
        return imp;
    }
                      <--Need another } here to finish the method
public int checkPred(int n){
    if(n>=1 && n <= 10 && n/2 <= 5){
        pred = 1;
    }
    else{
        pred = 0;
    }
    return pred;
}
}                   <-- extra } will cause another error - needs removing
It would help a lot to see errors like this if your code was formatted properly with indents (as above), it would then be obvious that something was missing.

Andy
cianz182's Avatar
cianz182 cianz182 is offline
Junior Member with 2 posts.
THREAD STARTER
 
Join Date: Nov 2011
Experience: Beginner
03-Nov-2011, 03:15 AM #3
Thank you very much for the advice!
cerma1993's Avatar
cerma1993 cerma1993 is offline
Junior Member with 6 posts.
 
Join Date: Nov 2011
Experience: Computer Illiterate
03-Nov-2011, 03:57 AM #4
specially thanks andy ..
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


Tags
error, illegal start expression, java

(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑