1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

java illegal part of expression

Discussion in 'Software Development' started by cianz182, Nov 2, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. cianz182

    cianz182 Thread Starter

    Joined:
    Nov 2, 2011
    Messages:
    2
    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.}
     
  2. andythepandy

    andythepandy

    Joined:
    Jul 2, 2006
    Messages:
    367
    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
     
  3. cianz182

    cianz182 Thread Starter

    Joined:
    Nov 2, 2011
    Messages:
    2
    Thank you very much for the advice!
     
  4. cerma1993

    cerma1993

    Joined:
    Nov 3, 2011
    Messages:
    6
    specially thanks andy ..
     
As Seen On
As Seen On...

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.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1025117