code for an array


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: code for an array

  1. #1
    bob Guest

    code for an array


    In my trying to understand java, and learning it as a beginner,
    i am trying to understand arrays and codes. if i had an array called Table
    of the integer type having 3 rows and 3 columns, and the constant variable
    size_of_array has been defined as 3, how would i write the code.

  2. #2
    Tom Duffy Guest

    Re: code for an array


    Hello Bob:

    What you are describing is a two dimensional array. You could declare the
    Table array like this:

    int[][]Table = new int[3][3];

    Then reference the cells in the array using 2 indexes. The first cell would
    be:

    Table[0][0] = some_int_value;

    You could easily use your size constant in place of the threes.

    Hope this helps.

    Tom Duffy

    "bob" <billybob2@ca.freei.net> wrote:
    >
    >In my trying to understand java, and learning it as a beginner,
    >i am trying to understand arrays and codes. if i had an array called Table
    >of the integer type having 3 rows and 3 columns, and the constant variable
    >size_of_array has been defined as 3, how would i write the code.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center