将字符串数组转换为散列表

将字符串数组转换为散列表

问题描述:

我有以下回应

I have the following response

T2269|175@@2a1d2d89aa96ddd6|45464047

通过使用 split(\\ |),我已将其转换为字符串数组对象。每个字段的含义如下:

By using the split("\\|") i have converted into string array object. The meaning for the each field is as follows:

T2269                  id
175@@2a1d2d89aa96ddd6  cid
45464047               refno

不,我必须将它转换成HashMap对象。他们的任何解决方案为上述..

No i have to convert it into HashMap object . Is their any solution for the above..

上面的回应是举例。实际上,字符串数组对象的长度是36。

The above response is given for example. In real, the length of the string array object is 36.

final String[] fields = input.split("\\|");
final Map<String, String> m = new HashMap<String, String>();
int i = 0;
for (String key : new String[] {"id", "cid", "refno"})
  m.put(key, fields[i++]);