Search:

Type: Posts; User: Norm

Search: Search took 0.14 seconds.

  1. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    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] += ...
  2. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    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...
  3. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    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.
  4. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    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...
  5. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    What error message did the compiler give you for the error? There could be an explanation there.
  6. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    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...
  7. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    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...
  8. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    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...
  9. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    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....
  10. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    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.
  11. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    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.
  12. Replies
    36
    Views
    5,755

    [SOLVED] Re: Array related assignment

    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;
Results 1 to 12 of 13