80 likes | 91 Views
Learn Core Java Training in Chennai from Accord which is the best java training institute in Chennai. Be job ready with our certification courses. Register with us today if you want to learn either just the basics and the core of java or J2EE which is advanced java training as we provide you with the best java courses in Chennai.
E N D
CORE Java Training in Chennai By Accordittraining.com
Array of java • Topics: 1. What is Array? 2. Array variables 3. Pass by reference 4. Multidimensional Arrays
What is an array? • An array is a very common type of data structure wherein all elements must be of the same data type. • Once defined, the size of an array is fixed and cannot increase to accommodate more elements. • The first element of an array starts with index zero. • Ex; x[0]=0; x[1]=1; x[2]=2; x[3]=3; x[4]=4; x[5]=5;
ARRAY VARIABLES • Using an array in your program is a 3 step process - 1) Declaring your Array 2) Constructing your Array 3) Initialize your Array • 1) Declaring your Array Syntax: <elementType>[] <arrayName>;
Contd…. • 2) Constructing an Array Syntax: arrayname = new dataType[] • 3) Initialize an Array Syntax: intArray[0]=1; // Assigns an integer value 1 to the first element 0 of the array intArray[1]=2; // Assigns an integer value 2 to the second element 1 of the array
PASS BY REFERENCE • Arrays are passed to functions by reference, or as a pointer to the original. This means anything you do to the Array inside the function affects the original.
MULTI DIMENSIONAL ARRAY • Multidimensional arrays are actually arrays of arrays. • To declare a multidimensional array variable, specify each additional index using another set of square brackets. • Ex: inttwoD[ ][ ] = new int[4][5] ; • When you allocate memory for a multidimensional array, you need only specify the memory for the first (leftmost) dimension. • You can allocate the remaining dimensions separately.
Contact us www.accordittraining.com EMAIL:enquiry@accordittraining.com CALL US (+91) 994 028 9059