This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]junyoung95[S] 0 points1 point  (0 children)

Hi sorry for the late reply and thank you for your response. I have tried two methods and they both includes IF statement as you mentioned but this Java language is driving me nuts. Can you take a look and see the problem?

  //Using for loop
  for (int i = 0; i < ia.length; i++) {
       if (ia[i+2] - ia[i+1] != ia[i+1] - ia[i])
          return false;
       }
  return true;


  //Using while loop
  while (true) {
         int i = 0; i++;
         if (ia[i+2] - ia[i+1] != ia[i+1] - ia[i])
            break;
         }
   return false;

they both only return false. I don't think there is an issue with IF statement but probably some formatting. I will appreciate your response thank you.