0
2 dimensional array and printing the randomly picked string - Java
Hi guys! I have a 2 dimensional array which I have gotten the computer to randomly a select an element from. The issue is I can't seem to print out the single element that was randomly selected? It print out something like "A1" or "B2" or something like that. https://code.sololearn.com/cBx1rHRtg9Sa/#java
3 ответов
+ 3
Remember the first dimension of a 2d array is always another array. Printing out an Object (in this case, the array) will give you the className+'@'+hex(hashcode()).
System.out.println(myArray[index]);
// Some array
System.out.println(myArray[index1][index2]);
// The element at index2 of the array at index1
+ 6
Just like the row value has been generated, the column value also must be generated for 2D array. There were other minor bugs too. Hope it helps :)
https://code.sololearn.com/c9D9SJCsAV0M/?ref=app
+ 1
you sir, are amazing thank you.