+ 1

Can you help me with this Java Array Program?[Solved]

Hi, I can't understand why it's not working. Please help me. https://code.sololearn.com/cB4vH9wtXY4C/?ref=app

6th May 2021, 4:05 PM
ltsRoy
ltsRoy - avatar
3 ответов
+ 2
It throw an error here m[i]=sc.nextDouble(); Why? You try to use a double type variable as array index. The index is integral value. A array index of 1.25 is invalid for example. How to solve it? You can cast the double to int m[(int)i] or change type of i from double to int
6th May 2021, 4:19 PM
john ds
john ds - avatar
+ 4
It's Roy declare i as int not double . as array index are of type int.
6th May 2021, 4:14 PM
TOLUENE
TOLUENE - avatar
7th May 2021, 2:21 AM
ltsRoy
ltsRoy - avatar