public class median { public static void median(int n,int ai[]){ if(n%2==1){ System.out.println((double)ai[(n + 1) / 2 - 1]); } else{ System.out.println((double)(ai[n / 2] + ai[n / 2 - 1])/2); } } public static void main(String args[]){ int ai[] = new int[2]; ai[0] = 4; ai[1] = 7; median(2, ai); } }