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

  • SEARCH
  • Home
  • 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 7854629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:07:37+00:00 2026-06-02T20:07:37+00:00

i wrote the following codes my aim is to get the lowst value of

  • 0

i wrote the following codes

my aim is to get the lowst value of doble[] absOfSub but it gives the following exception
at line compared= Double.compare(d2, d1);

Exception in thread "main" java.lang.StackOverflowError

why overflow and how to fix it?

EDIT

  public class TestThe {
static double[] absOfSub = new double[5];
    private static int index=0;

  private static int compare(int currentIdx, int minIdx) {
      if(index < absOfSub.length) {
         if(absOfSub[currentIdx] < absOfSub[minIdx]) {
             compare(currentIdx + 1, currentIdx);
         } else {
             compare(currentIdx + 1, minIdx);
         }
      }
  return minIdx;
  }

    public static void main(String[] args) {
    absOfSub[0]=1000;
    absOfSub[1]=810;
    absOfSub[2]=108;
    absOfSub[3]=130;
    absOfSub[4]=110;
double result;
   int inndex= compare(0,1);
      System.out.println(absOfSub[inndex]);
    
    }
}
  • 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-02T20:07:38+00:00Added an answer on June 2, 2026 at 8:07 pm

    How about this simple and elegant solution?

    static double min(double... ds) {
      double min = Double.POSITIVE_INFINITY;
      for (double d : ds) min = Math.min(min, d);
      return min;
    }
    
    public static void main(String[] args) {
      System.out.println(min(-5.2, 0, -10.1, 3));
    }
    

    Recursive solution (not recommended!):

    static double minRecur(double... ds) {
      return minRecur(ds, 0, Double.POSITIVE_INFINITY);
    }
    static double minRecur(double[] ds, int i, double runningMin) {
      return (i < 0 || i >= ds.length)? 
        runningMin : minRecur(ds, i + 1, Math.min(runningMin, ds[i]));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote codes for the following question but the output is not as expected.
i wrote following code to create a linkbutton programmatically, but its showing like lable
I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)':
I wrote the following code to select text from database,but when i echo the
I wrote the following codes. The problem should be the istringstream function. what did
i wrote following code to do some of a specifice column of gridview.. but
Good day! I am reviewing the Java OO concept. And wrote the following codes:
I wrote a query but I got following error, Any ideas ?! Error :
I wrote the following code, it works fine, but it takes like 3 sec
I wrote the following code, and I was expecting to get 5 6 6

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.