Collections in Java
Overview Array An Array is an indexed collection of fixed number of Homogenous data elements. The main advantage of arrays is we can represent multiple values by using single variable so that readability of the code will be improved. Limitations of Arrays Arrays are fixed in size i.e. once we create an array there is no chance of increasing or decreasing the size based on our requirement. Due to this, to use arrays concept compulsory we should know the size in advance which may not be possible always. Array can hold only homogenous data type elements. Student[] students = new Student[ 1000 ] ; students[ 0 ] = new Student( "Vim Payne" , 18 , 20 , 540 ) ; /* Prompts a compile time error: Incompatible types found: Teacher required: Student */ students[ 1 ] = new Teacher( "Vim Payne" , 18 , "St. Theressa School" , "9A" ) ; We can solve the above problem by using Object type arrays. Object[] students = new Object[ 1000 ] ; students[ 0 ] = new...