How to know if your input is equal to a random array number? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to know if your input is equal to a random array number?

i tried somthing like this but didnt work. int arr []= {1,2,3,4}; if(scan.equals(arr[rnd])){System.out.println("Same" );} else{System.out.println("not the same");

17th Aug 2017, 10:05 PM
D_Stark
D_Stark - avatar
2 Answers
+ 2
Take the input as a number and test: int input = scan.nextInt(); if (input == arr[rnd]) // equal else // not equal
18th Aug 2017, 4:58 AM
Rrestoring faith
Rrestoring faith - avatar
0
thanks faith ill try it out 👍
18th Aug 2017, 7:06 AM
D_Stark
D_Stark - avatar