JAVA || Count Items Matching a Rule
\n# Code\n\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n        int count = 0 ; \n        for( 
\n# Code\n```\nclass Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n        int count = 0 ; \n        for( int i = 0 ; i < items.size() ; i++){\n            switch (ruleKey) {\n                case "type":\n                    if(items.get(i).get(0).equals(ruleValue)){\n                            count++;\n                    }\n                break;\n                case "color":\n                        if(items.get(i).get(1).equals(ruleValue)){\n                            count++;\n                        }\n                    \n                break;\n                case "name":\n                     if(items.get(i).get(2).equals(ruleValue)){\n                             count++;\n                        }\n                break;\n            }\n        }\n        return count;\n    }\n}\n```
['Java']