if (nums[i] == nums[i+1] && nums[i] == nums[i+2]) {
To keep the above code (in red) from going off the end of the array.
Type: Posts; User: Norm
if (nums[i] == nums[i+1] && nums[i] == nums[i+2]) {
To keep the above code (in red) from going off the end of the array.
Take a look at the tutorial: The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)
or ask google. Many modern languages use the same syntax in for statements.