DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  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.



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links