我正在将一个arraylist转换为java中的一个集合,结果集合没有产生预期的结果。
column
我已经调试了这个但是当我从池中将addAll添加到hashset时,它只添加了数组的前11个字符。即使在我调试时,它表示pool = 19,它只会增加11.我是否称错了?它看起来很简单,但并没有全部添加。任何输入都非常感谢。
答案 0 :(得分:1)
XmlRootAttribute xRoot = new XmlRootAttribute();
xRoot.ElementName = "personList";
xRoot.IsNullable = true;
using (StreamReader reader = new StreamReader(xmlFilePath))
{
List<Person> result = (List<Person>)(new XmlSerializer(typeof(List<Person>), xRoot)).Deserialize(reader);
int numOfPersons = result.Count;
}
包含一个项目,或者它们没有。它们不包含多个副本。
在您的示例中,Set
中只有11个唯一字符CAPTAINAMERICAABCDE
。这就是你最终以11结束的原因。
您可能希望使用CAPTINMERBD
,因为这会允许同一事物的多个实例。