[Java] Maintain a Prefix Product (Handle the case when Element is 0)
```\nclass ProductOfNumbers {\n    static List prod;\n    static int p;\n    public ProductOfNumbers() {\n        prod = new ArrayList<>();\n        p = 1;\n   
```\nclass ProductOfNumbers {\n    static List<Integer> prod;\n    static int p;\n    public ProductOfNumbers() {\n        prod = new ArrayList<>();\n        p = 1;\n    }\n    public void add(int num) {\n        if(num == 0) {\n            prod = new ArrayList<>();\n            p = 1;\n            return;\n        }\n        p *= num;\n        prod.add(p);\n    }\n    public int getProduct(int k) {\n        if(prod.size() < k) return 0;\n        int ans = prod.get(prod.size() - 1);\n        if(prod.size() == k) return ans;\n        return (ans / prod.get(prod.size() - 1 - k));\n    }\n}
[]