Map To String
Map<String, String> map = new HashMap<String, String>();
map.put("Tom", "1988/01/01");
map.put("John", "1977/02/02");
String strMap = map.toString();
--------------------------------------------------------------------------------------
String To Map
String mapToString = "Tom=1988/01/01, John=1977/02/02";
Map<String, String> map = new HashMap<String, String>();
for(final String entry : mapToString.split(",")) {
final String[] parts = entry.split("=");
assert(parts.length == 2) : "Invalid entry: " + entry;
map.put(parts[0], parts[1]);
}
Log.d("tttttt","Map to String : "+map.get("Tom").toString());
歡迎轉載,請註明出處。
沒有留言:
張貼留言