View RSS Feed

Java Array

Declaring a Variable to Refer to an Array

Rate this Entry
by , 03-04-2012 at 11:02 AM (509 Views)
Array is declared in the above program along with this line of code.
Java Code:
// declares an array of integers
int[] anArray;
Array declaration also consists of 2 components, just like other declarations for other types of variables. They are
  • Array’s name
  • Array’s type


Array’s type is written as type[].

An array’s name could be anything that you may want provided it follows the conventions. Just like other type variables, array is not actually created by the declaration- this shows that variables would be holding specified type array.

In same way, the other types array could be declared.
Java Code:
byte[] anArrayOfBytes;
short[] anArrayOfShorts;
long[] anArrayOfLongs;
float[] anArrayOfFloats;
double[] anArrayOfDoubles;
boolean[] anArrayOfBooleans;
char[] anArrayOfChars;
String[] anArrayOfStrings;

Submit "Declaring a Variable to Refer to an Array" to Facebook Submit "Declaring a Variable to Refer to an Array" to Digg Submit "Declaring a Variable to Refer to an Array" to del.icio.us Submit "Declaring a Variable to Refer to an Array" to StumbleUpon Submit "Declaring a Variable to Refer to an Array" to Google

Tags: refer array Add / Edit Tags
Categories
Add

Comments