Array | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Array

Can you tell me the error in the following code I cannot sort it out... https://sololearn.com/compiler-playground/ctzKO4I1w6lq/?ref=app

2nd Jul 2024, 9:56 AM
Aditi Chand
Aditi Chand - avatar
9 Réponses
+ 1
an array can be declared like this: int [] marks = new int[3]; if you want to print the first element, remove the "" from the output
2nd Jul 2024, 10:21 AM
Lisa
Lisa - avatar
+ 1
I haven't code for Java for a while and forget how to create array. After reviewing my notes, I also found another you made. Instead of: int marks[0] = 89; It should be: marks[0] = 89; You already declared an integer array, so you don't need to assign an array member and state that it is an integer again.
2nd Jul 2024, 12:40 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
Okk Thanku now its done I will try to be more clear with these syntax
3rd Jul 2024, 5:56 AM
Aditi Chand
Aditi Chand - avatar
0
Lisa its still not done
2nd Jul 2024, 10:54 AM
Aditi Chand
Aditi Chand - avatar
0
carefully compare my example and your line 7. which part is missing in your code?
2nd Jul 2024, 11:09 AM
Lisa
Lisa - avatar
0
Aditi Chand look at Lisa's reply carefully. this ⬇️ int[] marks = new int[3]; your code: int marks = new int[3]; type int is not the same as type int[]. one is integer, the other is integer array
2nd Jul 2024, 11:16 AM
Bob_Li
Bob_Li - avatar
0
Can you just do it and share it please
2nd Jul 2024, 11:21 AM
Aditi Chand
Aditi Chand - avatar
0
don't be lazy... if you can't see the mistake now, you should redo the lesson. Don't build on shaky foundations.
2nd Jul 2024, 11:22 AM
Bob_Li
Bob_Li - avatar
0
Wong Hei Ming those new errors must have been added afterwards. They were not there when I looked at the code. Now there are more mistakes in the code. Please redo the lesson. The basics are very important. Do not guess the correct syntax.
2nd Jul 2024, 1:05 PM
Bob_Li
Bob_Li - avatar