public static void main(String args[]) { Scanner sc = new Scanner(System.in); String s[] = new String[5]; System.out.println("Введите числа"); for(int i=0; i<5; i++) { s[i] = sc.next(); } Object obj = s; if(obj instanceof Integer) { int num[] = new int[5]; for(int i=0; i<5; i++) { num[i] = Integer.parseInt(s[i]); } int aver = fun(num); System.out.println(); System.out.println(aver); } if(obj instanceof Double) { double num[] = new double[5]; for(int i=0; i<5; i++) { num[i] = Double.parseDouble(s[i]); } double aver = fun(num); System.out.println(); System.out.println(aver); } sc.close(); } } 
  • 2
    What kind of s do you think? - VladD

1 answer 1

Because you are comparing an array of strings with a number.