• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with arrays

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given a 50 element array called fifty and random numbers between 0 and 49, count the occurrences of each number by incrementing the corresponding element (i.e., if a 3 is generated, then element at index 3 is incremented by 1). You should use a for-loop to generate 235 random numbers. Output the results of the fifty array:
Random gen = new Random( );
int num;
//for-loop to generate 235 random numbers
num = gen.nextInt(50); //generates one random number from 0 to 49
//output fifty array

* I need help understanding how to do arrays. Can some one explain the steps in completing the code above?
 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There you go
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
reply
    Bookmark Topic Watch Topic
  • New Topic