The 2 dim array holds student data. The i index is for the student and the j index is for the scores for that student.
studentSum[i] = studentSum[i] + student[i][j];
or
studentSum[i] += ...
Type: Posts; User: Norm
The 2 dim array holds student data. The i index is for the student and the j index is for the scores for that student.
studentSum[i] = studentSum[i] + student[i][j];
or
studentSum[i] += ...
I don't see where your println() is that generated the output you show.
[I@3e25a5 is what is generated by the toString() method for the array object. Arrays are objects. The Object class has a...
The assignment statement in the for loop is assigning a value to an element (at i-1) of the array my2dArray.
The value being assigned is another array of dimension i.
What is the it in the above?
A variable or an element of an array can only hold one value at a time. You can change the values one after the other so that it has held all the values. But at any...
What error message did the compiler give you for the error? There could be an explanation there.
That's what the JVM will give you when you ask for a String representation of an object that does not have a toString() method to convert it for human viewing. Arrays are objects. The String...
I try to write a short program to test before posting. The following compiles and executes.
public class TestArrayDef {
public static void main(String[] args) {
int twoDim[][] = new...
I don't see an I in what you posted. I do see an i. Case is important in Java i and I are different.
The variable i in twoDim[i] is an index into the twoDim array. The statement
twoDim[i] = new...
Each dimension of an array must be initialized separately.
int[][] twoDim = new int[5][]; // define a two dim array
So now twoDim has 5 empty slots where there needs to be added one dim arrays....
Try copy and paste of any one of the above into a main() method.
Are you able to write a "Hello World" program?
Take that program and insert into it one of the above.
Try writing a small program using the above examples. Make some changes, set one of the elements, display some of the elements.
Come back when you have problems. Post the code and the errors.
int twoDim[][] = new int[5][]; // create a two dim array with second dim unassigned
Then to add second dim:
twoDim[0] = new int[4];
To put data in:
twoDim[0][0] = 123;