0

How to get element of the array from user?

any example

2nd Jun 2018, 7:18 AM
Janani B
Janani B - avatar
2 Answers
+ 3
for(int i = 0; i < array.length; i++) array[i] = sc.nextInt(); sc is an instance of the Scanner class. You can variably use any other Scanner methods (nextLine(), etc.) depending on the code requirements.
2nd Jun 2018, 7:25 AM
Dev
Dev - avatar
0
Initialize an array, read the user input and assign its value to a given position in the array...
2nd Jun 2018, 7:25 AM
Jiƙí Bočan