r/learnjava • • Jun 22 '22

Missing '}' or illegal start of expression

Hello,

The code below is presenting a "missing '}' or illegal start of expression" error. I'm kind of confused what could be causing this. I'm sure it is very simple but I'm obviously not understanding why this boolean return isn't allowed.

public boolean array123(int[] nums) {
  boolean seqExist = false;
  for(int i = 0; i < (nums.length-2); i++){
    if (nums[i] == 1) && (nums[i+1] == 2) && (nums[i+2] == 3) {
      seqExist = true;
    } 
  }
  return seqExist;
}
1 Upvotes

8 comments sorted by

View all comments

7

u/unicanor Jun 22 '22

(nums[i] == 1) && (nums[i+1] == 2) && (nums[i+2] == 3)

should be

((nums[i] == 1) && (nums[i+1] == 2) && (nums[i+2] == 3))

1

u/Bunnymancer Jun 22 '22

If only there was a better way..

1

u/Nyos_ Jun 22 '22

I am curious now, what would be a better way?

1

u/Dangerous-Rip-7370 Jun 22 '22

Use online the first ( and the last)