使用HashMap比较字符串

s0lus

我有几个这样的xml文件

<?xml version = "1.0"?>
<note>
<to>Tim</to>
<from>Joe</from>
<head>About Job</head>
</note>

<?xml version = "1.0"?>
<note>
<to>Tim</to>
<from>Joe</from>
<head>How are u?</head>
</note>

 <?xml version = "1.0"?>
<note>
<to>Marry</to>
<from>Pit</from>
<head>Welcome to home</head>
</note>

我解析此文件并将数据存储到这样的文本文件中

FROM: 
   Tim
   Tim
   Pit
TO: 
   Joe
   Joe
   Marry
HEAD: 
   About Job
   How are u?
   Welcome to home

我希望名称不重复使用hasMap我该怎么办,请帮帮我!:)

他们是

如果只需要唯一的名称集合,请使用HashSet<String>每个唯一名称仅存储一个实例。HashMap如果您希望将每个唯一的名称用作键,则将很有意义。在这种情况下,您必须确定要存储的内容作为每个名称键的值。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章