Tutorial #6 : Array



It is a collection of similar type of element which store in fix size. Array start '0th' index. Declare single variable and can assign multiple value to that.

Types
1. Single D. Array
2. Multi D. Array

Syntax

int[] ar;                          OR         int[]ar = new int[3];
ar = new int[3];
ar[0]=10;
ar[1]=85;
ar[2]=30;


  • Datatype 


1. Value type:- Data will store on stack directly .
     eg. int a = 10;
           int b = 20;
     
2. Reference type:- Data will store on MH index and memory address of data will store in stack.
     eg.  int[]ar = new int[3];
            ar[0]=10;
            ar[1]=85;
            ar[2]=30;


  •     Array copy of :- 

    
    int[] marks1 = Arrays.copyOf (marks,marks.length);



  • Array sort :- 


Arrays.sort(marks);






Comments