Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Fubarable

Thread: help!!!

  1. #1
    Join Date
    Jan 2012
    Posts
    2
    Rep Power
    0

    Default help!!!

    Java Code:
    public boolean magic()
         {
        
           
           if ((sumMainDiag())==sumOtherDiag())
        {
        int sumRow=0;
        int sumCol=0;
        int row=0;
        int col=0;
      
    
        for(int t =0; t<(square.length); t++)
        {
       
        sumRow += square[row][t];
        sumCol += square[t][col];
     
        if (sumRow ==sumCol)
           { 
               boolean magic = true;
            }
       
           
        else  {
             boolean magic = false;
       
        
            }
           
        
    
    }
     
    }
    else{
            
                boolean magic= false;
            }
     
        }
    there is a missing return statement error and its highlighting the last brace in red when i compile
    Last edited by Eranga; 01-17-2012 at 07:00 AM. Reason: code tags added

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: help!!!

    Well, where do you return anything? i.e., where is there a statement that starts

    Java Code:
       return ....
    I think you'll want to read up on how to create methods and return values from them. Please have a look here:

    Defining Methods
    Returning a Value from a Method
    Eranga likes this.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •