Java Array basic problem | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Java Array basic problem

I am faced with this so-called 'basic' problem, but the newbie that I am needs your help. I am to make a code that determines who among your friends is your bestest friend. That is, The first line contains an integer n which is the size of the array. The next n lines contains a string on each. The last line contains an integer which is the index to be accessed and printed. Input: 3 Jane Nina Ken 2 Output: Your friends are: Jane Nina Ken Your best friend is: Ken I am yet to figure out the code for determining the best friend. Below is my code, https://code.sololearn.com/ca24a17A11a1

8th Jul 2021, 5:15 AM
Eka
Eka - avatar
1 Resposta
+ 3
Eka Just take index input then get best friend like System.out.print(names[index]);
8th Jul 2021, 5:22 AM
AĶ¢J
AĶ¢J - avatar