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 8733229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:36:30+00:00 2026-06-13T09:36:30+00:00

I am trying to find the max integer of an array where number =

  • 0

I am trying to find the max integer of an array where number = [10]. My method prints out 0, not the max integer.

public static void maxArr (int[] number){ 
        int max = number[0];
        for(int i = 1; i<number.length; i++){
            if(number[i]> max){
                max = number[i];
            }
        } System.out.print(max);
    }
  • 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-13T09:36:31+00:00Added an answer on June 13, 2026 at 9:36 am

    You aren’t filling your array correctly.

    In java, when you first create an array with private int[] myArray, it is null (that is, it doesn’t represent an actual thing yet, it’s just a name that could point to an array in the future). Next, you somehow tell it how many elements it will hold. There are 2 commonly used ways to do this:

    The first is something that looks like myArray = new int[42]; This will initialize the array, but every slot will be zero (or worse, null if it’s an array of Objects). You can fill one of its individual slots (in this case, the 4th slot) with myArray[3] = 13. This will store the int 13 in slot 3 of myArray. Array slots start counting at 0, so if you want the first element you call myArray[0], if you want the second one you call myArray[1], and so on. You can use a for loop to populate an entire array with just a few lines of code:

    for (int i = 0; i < myArray.length; i++) {
        myArray[i] = 10;
    }
    

    Your array is now ready to be used for whatever its purpose in life happens to be.

    The second way to fill your array happens when you initialize it. It looks like myArray = new int[] {10, 42, 24, 64, 8, 16, 3}; Anything you put into the curly brackets is now in the array, so the value of myArray[0] is now 10, and the value of myArray[1] is now 42, and so on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find the max number in an array. I have created
I am trying to find out the maximum value for an integer (signed or
I'm trying to find out max available area on my printer. I've printed a
I am trying to find the max number in a column of one of
I am trying to find out programatically the max permgen and max heap size
I'm trying to find the max value contained in two separate fields of my
Trying to find out if it's possible to use SQLAlchemy on Heroku. Thanks.
Trying to find a good name for a method swapping each coordinate X and
Trying to find examples of when decorators might be really beneficial, and when not
i am trying to find the max values of a sum result but i

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.