Thursday, 12 March 2015

ARRAY: (Core JAVA)

{              ArrayType [] arrayname; or
ArrayType arrayname[];
Arrayname= new ArayType[size];            } or
ArrayType[] arrayname= new ArrayType[size];
·         Array is a collection of similar type which has fixed size and it cannot store dissimilar type
·         Array can be initialize in 2 ways
(1)    By using dimensions
(2)    By using initialize
·         Syntax for initializing array using dimensions
ArrayType[] arrayname= new ArrayType[size];

·         Syntax for initializing array using initialize
ArrayType[] arrayname= { , , , };
·         Using array initialize, the elements are separated by ‘,’
·         We can refer each element of an array using index
·         The element of an array can be sorted by using sort method
·         Sort method is a public static method of array’s class
·         Array’s class belongs to a package java.util
·         sort method is overloaded method of arrays class. This method sorts the element of an array and stores the sorted element in the same array.
·         Array can be of 2 types
(1)    Primitive array- Boolean, int etc(PRIMITIVE DATATYPES)
(2)    Derived array- objects etc

·         If array of class type is created, then in that array we can store any type of object which is subclass to array’s class

No comments:

Post a Comment