Easy & clean solution with switch statement
\n\nclass Solution {\n    public int countMatches(List> items, String ruleKey, String ruleValue) {\n       int count=0;\n        for(List item: items) {\n      
```\n\n```class Solution {\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n       int count=0;\n        for(List<String> item: items) {\n            switch(ruleKey) {\n                 case "type":\n                    count += item.get(0).equals(ruleValue)?1:0;\n                    break;\n                case "color":\n                    count +=item.get(1).equals(ruleValue)?1:0;\n                     break;\n                case "name":\n                    count +=item.get(2).equals(ruleValue)?1:0;\n                     break;\n            }\n        }\n        \n        return count;\n    }\n}
['Java']