gpt4 book ai didi

java - 迭代器 hasext 给出第二个值

转载 作者:行者123 更新时间:2023-12-02 05:55:31 25 4
gpt4 key购买 nike

就我而言,我想使用新的 HashSet set 删除 leveranciers 中的重复字符串。调试后似乎可以工作,但是当我调用 it.hasNext 时。它将直接使用 0230 而不是 6023...请需要一些帮助,我不习惯使用 Iterator 和 HashSet。

String[] leveranciers = new String[wdContext.nodeShoppingCart().size()];

//Filledin leveranciers with '6023', '6023' and '0230'

//Remove duplicates from array
Set set= new HashSet(Arrays.asList(leveranciers));

for (Iterator it = set.iterator(); it.hasNext(); ) {
PdfPTable table = GetTable(""+ it.next());
byte[] pdf = wdThis.wdGetAchatsIndirectController().GetPDFFromFolder("/intranetdocuments/docs/AchatsIndirect", table);
wdThis.wdGetAchatsIndirectController().PrintPDF(pdf);
}

最佳答案

关于 Set 的事实在java中它不能包含重复的值,那么你的设置值将是 6023 and 0230仅。

Java 文档:

A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element.

关于java - 迭代器 hasext 给出第二个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23128615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com