• Post Reply Bookmark Topic Watch Topic
  • New Topic

array returns error  RSS feed

 
adebari olalekan
Ranch Hand
Posts: 61
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


am trying to generate a random number and storing it in a variable  to show the frequency of the number occurrences in a thousand

then it returns this error:

>
 
Campbell Ritchie
Marshal
Posts: 56527
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That isn't an error. That is what always happens if you print an array because it doesn't override Object#toString(). You probably want to print the individual elements with myArray[i] instead.
By the way: your array is a local variable and shou‍ld therefore not have a CapitalLetter at its start. Please space out your operators:-
for (int roll = 1; roll < 1000; roll++) {
We have some formatting suggestions here (see 1.2).
Please work out how to print i + 1 in line 16. That way you can get rid of all the other instances of + 1 and start your for loop from 0. It will be a good exercise in writing loop indices.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!