[Java] Simple Use String REPLACE
Understand the problem:\n1.     You need to replace certain keys with some values \n2.     You can use a map to keep a record of the keys and values\n3.     Ite
**Understand the problem:**\n1.     You need to replace certain keys with some values \n2.     You can use a map to keep a record of the keys and values\n3.     Iterate the keys to replace all the occurrences of its keys in the text\n\n```\nclass Solution {\n    \n    public String entityParser(String text) {\n        if (text == null || text.length() == 0) {\n            return "";\n        }\n\n        Map<String, String> map = new HashMap<>();\n        map.put("&quot;", "\\"");\n        map.put("&apos;", "\'");\n        //map.put("&amp;", "&");\n        map.put("&gt;", ">");\n        map.put("&lt;", "<");\n        map.put("&frasl;", "/");\n        \n        for (String key:map.keySet()) {\n            text = text.replaceAll(key, map.get(key));\n        }\n\t\ttext = text.replaceAll("&amp;","&");\n        return text;\n    }\n}\n```
[]