+ 1

How can I make this game (code) correct? When you see the code you will understand what I was trying to do... plz help

https://code.sololearn.com/cx3pA0bjN8NC/?ref=app

5th Apr 2020, 12:31 PM
Yahel
Yahel - avatar
6 Answers
0
use: String y= name[random.nextInt(3)]; random.nextLine does not exist.
5th Apr 2020, 1:00 PM
Bahha┣
Bahha┣ - avatar
+ 1
because you are trying to access name[ ] elements using a random index. and array indexes are of type int. name[0] name[1] name[2]
5th Apr 2020, 1:14 PM
Bahha┣
Bahha┣ - avatar
+ 1
Bahha🐧 thank you!
5th Apr 2020, 1:18 PM
Yahel
Yahel - avatar
0
Are you trying to take a user input and then trying to produce a random word from the array and see who wins the game?
5th Apr 2020, 12:55 PM
Avinesh
Avinesh - avatar
0
Avinesh I made that you can only write (in the Scanner) rock, paper or scissors (like I wrote here, or in capital letters). And then i am trying to make a Random from an array..
5th Apr 2020, 12:57 PM
Yahel
Yahel - avatar
0
Bahha🐧 thank you! It worked! But why is it an "int"? Its a word.. shouldn't it be a "nextLine"?
5th Apr 2020, 1:11 PM
Yahel
Yahel - avatar