Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9107421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:34:03+00:00 2026-06-17T02:34:03+00:00

i have to write a method, The method receives a parameter of two-dimensional array

  • 0

i have to write a method,
The method receives a parameter of two-dimensional array of integers. The method returns the number of the row which has the highest sum of the integers.I’m allowed to use only recursion! no loops allowed!-of course i need to make a private method that will sum a row as a single array and then i have to do another private method that compares the rows, but it doesn’t really work since the method i wrote is only for a 1d array, and i need to compare a row from a 2d array..

appreciate all kind of help..

some of my code:

private  int rowSum(int[] array, int index) {//the sum of an array(1d array)
        if (index == array.length)
            return 0;
        else
            return array[index] + rowSum(array, index + 1);
    }

**public int maxRow(int[][] a){------!!!---the problem...

    }**
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:34:04+00:00Added an answer on June 17, 2026 at 2:34 am

    Code:

    public class MainClass {
        static  int contents[][] = { {1, 2 , 3, 4} , { 4, 5, 8, 7}, { 4, 2, 8, 7}, { 4, 5, 0, 7} };
        public static void main(String[] args) 
        {
            System.out.println(getIndexOfRowWithHighestSum(contents, 0, 0));
        }
        public static int getIndexOfRowWithHighestSum(int[][] twoDAray, int currentIndex,int indexWithHighestSum){
            if(currentIndex>=twoDAray.length){
                return indexWithHighestSum;
            }
            int sum1 = getSumOfArray(twoDAray[currentIndex], 0) ;
            int sum2 = getSumOfArray(twoDAray[indexWithHighestSum], 0);
    
            indexWithHighestSum = (sum1 > sum2)?currentIndex:indexWithHighestSum;
    
            return getIndexOfRowWithHighestSum(twoDAray, currentIndex+1,indexWithHighestSum);
        }
        public static int getSumOfArray(int[] array, int currentIndex){
            if(currentIndex>=array.length){
                return 0;
            }
            return array[currentIndex]+getSumOfArray(array,currentIndex+1);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that receives a customer object which has changed properties and
I have a method that receives a number n as parameter and calculate all
I have write my own view Bar, which extends LinearLayout . My bar has
I have one method that receives a Stream to write on it using a
I have a method which receives a file over a TCP socket using this
I have a class using ReaderWriterLockSlim with a read method and a write method
I have a method which writes into a database the username and password of
I have and old(ish) C# method I wrote that takes a number and converts
I have this method to write messages to a socket: public void sendMessage(byte[] msgB)
the following splitter method is designed to return a IntLinkedBag array of two separate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.