0

Dear all,

I have a test tomorrow and I just wanted to double check on my answer for this review question.

Write a method negativePositive that takes an array of integers, and returns an array that contains 3 integers. The first value in the returned array is the number of negative integers in the array, the second value is the number of zeroes in the array, and the third value is the number of positive integers in the array.

negativePositive({4, 90, -3, -1, 0, 0, 88, -5, -2}) -> [4, 2, 3]

```
public static int[] negativePositive(int[] arr)
{
int[] ret = new int[3];
int i = 0, e = arr.length;
while (i < e)
{
if (arr[i] < 0)
{
ret[0]++;
i++;
}
if (arr[i] == 0)
{
ret[1]++;
i++;
}
if (arr[i] > 0)
{
ret[2]++;
i++;
}
}
```

Thank you.