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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:22:04+00:00 2026-05-28T06:22:04+00:00

I am supposed to create an array of 1000 ints and write a method

  • 0

I am supposed to create an array of 1000 ints and write a method to find the largest int and then print it. This is what I have so far:

public static int findLargest(int[] numbers){  
    int largest = numbers[0];  
    for(int i = 1; i < numbers.length; i++){  
        if(numbers[i] > largest){  
            largest = numbers[i];  
        }  
    }  
    return largest;
}

First, how do I create an array with 1000 randomly generated ints? I tried int[] array = new (int)(Math.random()); but I don’t know how to get it to do 1000 random numbers. Second, how do I print the result? Thanks in advance for any help.

  • 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-05-28T06:22:04+00:00Added an answer on May 28, 2026 at 6:22 am

    Eyeballing it, your findLargest method looks good — it is using the correct approach.

    To generate the list of 1000 numbers, you need to initialize the array to 1000 elements. Right now you are initializing it to have a random number of elements, which is not what you want. After you initialize the numbers to be an int[] of length 1000, you need to loop over the array putting a random number in. Some something like

    int [] numbers = new int[1000]; // generate a new int[]
    
    for (i = 0; i < number.length; i++) {
      numbers[i] = xxxx; // generate a random number
    }
    

    You should probably create some sort of init method that creates the original array for you. You would invoke it in main, get the reference to the array, then pass that array to your find method, then print the result.

    You are almost there.

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

Sidebar

Related Questions

I'm supposed to create an array and sort the numbers from smallest to largest.
Suppose I have an array of nodes (objects). I need to create a duplicate
I have the following code, which is supposed to create a form on the
There is an array of integers, lets say 3,5,7,9. You are supposed to create
I am supposed to print an array of invoices to our clients. There is
I have here a program that is supposed to begin with an array of
For this question, I'm supposed to create a NxN powers table in matlab using
I have this error again: Notice: Undefined index: IDNUMBER in E:\wamp\www\PHP\create.php on line 5
I have extended LinearLayout (vertical) to create a custom compound component. This in turn
So I have this Excel workbook which basically is supposed to be a data

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.