Java
  Home arrow Java arrow Page 3 - Primitive Data Types and Basic Languag...
FaxWave - Free Trial.
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Primitive Data Types and Basic Language Rules for Java
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2007-09-24

    Table of Contents:
  • Primitive Data Types and Basic Language Rules for Java
  • Working with Arrays
  • Multidimensional Arrays
  • A Few More Rules

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Virtual Tradeshows by Ziff Davis Enterprise - A Unique Opportunity to Connect with IT Experts, Access Information, and Gain Insight on today's Technology

    Primitive Data Types and Basic Language Rules for Java - Multidimensional Arrays
    (Page 3 of 4 )

    If we want to get crazy (and deciding to learn any programming language is a sure indicator that you do), Multidimensional Arrays offer you a way to get there. The following code demonstrates how to declare a two-dimensional array.

    Int YourTwoDimensionalArray [] [] = new int [8] [8];

    What the above code does is give us an 8x8 array. Think of the way a chess board looks: a grid of 8 rows and 8 columns.




















    Each of the above boxes would hold two indexes; the left index is used for the row, the right index is used for column


    When you allocate memory for a multidimensional array, you only have to set memory for the left dimension. You can allocate the right dimension at a later time, as in the following code.

    Int YourTwoDimensionalArray [] [] = new [5] [0]

    YourTwoDimensionalArray[0] = new int [2]

    YourTwoDimensionalArray[0] = new int [7]

    YourTwoDimensionalArray[0] = new int [20]

    YourTwoDimensionalArray[0] = new int [25]

    YourTwoDimensionalArray[0] = new int [12]

    Note also that if you ever need to know the length of an array the following code will print it to your screen:

    System.out.println(YourArray.length);

    More Java Articles
    More By James Payne


       · This article covers Primitive Data Types in Java. I hope it proves useful. If you...
     

       

    JAVA ARTICLES

    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup
    - Using RPC-Style Web Services with J2EE
    - Integrating XML with J2EE
    - Taming Tiger: Concurrent Collections
    - Combating the ‘Object Crisis’

    Iron Speed



    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway