Results 1 to 4 of 4

Thread: matrix values

  1. #1
    Ike
    Ike is offline Member
    Join Date
    Aug 2011
    Posts
    21
    Rep Power
    0

    Default matrix values

    How to access matrix members?

    I've declared a matrix:

    double [] [] chess = new double [3][3];

    When I want to access a field, I can't.
    What's the correct syntax?

    How do I give values to the members.. like:

    chess [2][3] = 7;

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Re: matrix values

    What have you tried? Also, these aren't really matrices, they are 2 d arrays. Each element in the array is itself another array.

    So chess would have 3 elements in array 0, 3 in 1, and 3 in 2.

    Java Code:
    chess[0][0];
    chess[0][n];
    chess[n][0];
    chess[n][n];

  3. #3
    Ike
    Ike is offline Member
    Join Date
    Aug 2011
    Posts
    21
    Rep Power
    0

    Default Re: matrix values

    Yes, but how do I write numbers into it?
    Last edited by Ike; 11-05-2011 at 02:45 AM.

  4. #4
    Ike
    Ike is offline Member
    Join Date
    Aug 2011
    Posts
    21
    Rep Power
    0

    Default Re: matrix values

    Ok, so that was the correct syntax, it was just me trying to give values outside of any method....

Similar Threads

  1. Matrix
    By awesom in forum New To Java
    Replies: 9
    Last Post: 10-05-2011, 08:36 PM
  2. Replies: 14
    Last Post: 01-22-2011, 02:36 PM
  3. help in matrix
    By Engineer in forum New To Java
    Replies: 7
    Last Post: 10-06-2010, 01:26 PM
  4. Replies: 0
    Last Post: 05-22-2008, 10:53 AM
  5. Help with matrix
    By susan in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 04:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •