Map<String,Object> inputMap=new HashMap<String,Object>();
inputMap.put("a","abc");
inputMap.put("b","bcd");
inputMap.put("c","cde");
HashMap<String,String> subMap=new HashMap<String,String>();
subMap.put("x","xyz");
subMap.put("z","klm")
inputMap.put("d",subMap);
String output=inputMap.toString();
System.out.println(output);
{a=abc,b=bcd,c=cde,d={x=xyz,z=klm}}
la sortie est la suivante: {a = abc, b = bcd, c = cde, d = {x = xyz, z = klm}}; Comment puis-je convertir la sortie en Carte?Je convertis une carte en chaîne en utilisant la méthode toString(). Est-il possible de convertir la chaîne en carte?
Merci d'avance.
double possible de [Convertir chaîne représentant des paires clé-valeur à la carte] (https://stackoverflow.com/questions/14768171/convert-string-representing-key- value-pairs-to-map) –
Essayez d'utiliser la méthode clear(). Il supprime toutes les paires clé/valeur de la carte invoquante. – Tehmina
Voici une solution: https://stackoverflow.com/a/17278809/1270000 – sorifiend