```
class Solution {
public int maximumProduct(int[] nums) {
int first = Integer.MIN_VALUE;
int second = Integer.MIN_VALUE;
int third = Integer.MIN_VALUE;
int sfirst = Integer.MAX_VALUE;
int sSecond = Integer.MAX_VALUE;
for(int num : nums){
if(first < num){
third = second;
second = first;
first = num;
}
else if(second < num){
third = second;
second = num;
}
else if(third < num){
third = num;
}
if(sfirst > num){
sSecond = sfirst;
sfirst = num;
}
else if(sSecond > num){
sSecond = num;
}
}
return Math.max(first * second * third, first * sfirst * sSecond);
}
}
```