For declaring one dimensional array:
Array is used typically to group objects of same data type. Array enables you to refer to a group of objects by a common name; you don't have to remember all variable names. You can declare arrays of any type, either primitive or class:
Char [] s;
Point [] p; // where point is a class
When declaring arrays with the bracket to left, the brackets apply to all variables to the right of brackets.
In the JAVA programming language, an array is an object even when the array is made up of primitive type, and as with other class types, the declaration does create the object itself. Instead, the declaration of an array creates a reference that you can use to refer to an array. The actual memory used by the array element is allocated dynamically either by a new statement or by an array initialize.
You can declare arrays using the square brackets after the variable name:
Char s [];
Point p [];
This is standard for c, c++ and the JAVA programming language. This format leads to complex forms of declaration that can be difficult to read.
The result is that you can consider a declaration as having the type part on the left, and the variable name on the right. You will see both formats used, but you should decide on one or the other for your own use. The declarations do not specify the actual size of array.
For declaring the multidimensional array:
For declaring multidimensional arrays in the JAVA programming language does not provide in the same way that other language do. Because you can declare an array to have any base type, you can create arrays of arrays (and arrays of arrays of arrays, and so on). The following example shows a two dimensional arrays:
Int [] [] twodim = new int [4] [];
Twodim [0] = new int [5];
Twodim [1] = new int [5];
The object is created by the call to new is an array that contains four elements. Each element is a null reference to an element of type array of int and you must initialize each element separately so that each element points to its array.
Published by Harsh Gupta - Tech Writer
I am a part time freelancer and writing is my hobby Some of my websites: http://www.GenericArticles.com http://www.JailBreakingiPhone.com View profile
- Top Ten Gift Ideas for TeachersDon't know what to buy that special teacher? Top Ten Gift Ideas for Teachers highlights some wonderful gift ideas any teacher would love to receive.
- Educating for Sustainability in the Philippine ContextEducation is the individual's key to liberate ones' self not just from ignorance, but from poverty, and all the evils that corrupt the society. Education empowers the individual, and to that, empowers an entire commun...
- C++ Arrayarrays are the easiest ways to make groups of objects in C++. See some examples, or if you're in a hurry then see 3 tips for using arrays that'll tell you everything you need to know.
- Bilingual Education Policy and It's Promises and Problems for Native American Engl...Native Americans as a group are frequently ignored but significantly impacted by Federal, State and Local bilingual education policies. Can America afford to keep a bilingual education system that is becoming increasi...
- Research Firm: North American Businesses Ill-Equipped to Deal with Data-Destroying...The Info-Tech Research Group released a statement on Monday declaring that businesses in North America are still mostly quite poor at planning for possible IT crises.
- A Short Introduction to Java Programming Language
- Java Programming Tutorials: The Online Give and Take
- Understanding Java
- A Multidimensional Array for Horizontal Web Page Menus
- Multidimensional Arrays in Perl 5.0: A Boon to Bioperl (Part 1)
- JavaScript Multi-Dimensional Array
- PHP Variable Scope Basics
