Tech Support Guy banner
Status
Not open for further replies.
1 - 4 of 4 Posts

·
Registered
Joined
·
2 Posts
Discussion Starter · #1 ·
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.}
 

·
Registered
Joined
·
379 Posts
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;
    }
                     [COLOR="Red"] <--Need another } here to finish the method[/COLOR]
public int checkPred(int n){
    if(n>=1 && n <= 10 && n/2 <= 5){
        pred = 1;
    }
    else{
        pred = 0;
    }
    return pred;
}
}                 [COLOR="Red"]  <-- extra } will cause another error - needs removing[/COLOR]
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
 
1 - 4 of 4 Posts
Status
Not open for further replies.
Top