1
//import java.util.Arrays;
import java.util.*;

public class Solution {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int size = sc.nextInt();
        int arr[] = new int[size];
        int u=0;
        for (int i = 0; i < size; i++) {
           u=sc.nextInt();
            arr[i] = u;
        }
        System.out.println(arr);
        int pos = 0, neg = 0, zero = 0;
        for (int i:arr) {
            if (i > 0) {
                pos += 1;
            } else if (i == 0) {
                zero += 1;
            } else {
                neg += 1;
            }
        }
        System.out.println(pos / size);
        System.out.println(neg / size);
        System.out.println(zero / size);
    }
}

this was my code to print the ratio of positive negative and zero's present in my array but in the print statement where i am printing the array, it is showing this [I@7cc355be

1 Answers1

1

The right way to print an array in one line would be:

System.out.println(Arrays.toString(arr));
Majed Badawi
  • 27,616
  • 4
  • 25
  • 48