public class lalak
{
    public static void m1(int[] array)
    {
         array= new int[]{1,2,3,4,5};
        System.out.println(array[2]);
    
    
    }
    
    public static void main(String[] args)
    {
        int[] array = {1,1,1,1,1};
        m1(array);
        System.out.println(array[2]);
        
        
        
    }
}
why answer is 1, not 3?
i expected the program to print 3 but i got 1 as output. i thought method would change my original array but it turned out to be false. does anyone know the reason for this?
 
    