Ad
  • Custom User Avatar

    I did, it seems you didn't. Let's show you your code structure so you can see it:

     public class Sum
     {
      public int GetSum(int a, int b)
      { 
          if () {
          }
          else if (){
             for () {
             }
             else if () { // this is the one that's wrong, it comes after a for, not an if or an else if
               for () {             
               }
             }
        }
        return
      }
    }
    

    You misplaced some }. Read this: https://docs.codewars.com/training/troubleshooting#post-discourse and use markdown formatting in your code so it's easier to read when you post it here, please.

  • Custom User Avatar

    You have an else after a for. Reading the error message helps:

    src/main/java/Sum.java:11: error: 'else' without 'if'
             } else if(a < b){
               ^
    1 error
    

    It tells you exactly in which line you have the problem. Before your else if you need another else if or an if.