5 Topics

Member Avatar for
Member Avatar for anand01

hi all, As of my understanding hash set will not allow duplicates. But when I add two different object of same class with same value it is accepting, at the same time same object with different values are not accepting.Kindly clarify me Senario-1 TestBean testBean = new TestBean(); testBean.setId(1); testBean.setId(100); …

Member Avatar for JamesCherrill
0
226
Member Avatar for Derek_4

For some reason this is only returning the description of a single item in the HashSet even when there are several items. I am not sure if the (Item)iter.next() is only getting the description of the first item in the list and that is why. /** * */ public String …

Member Avatar for JamesCherrill
0
224
Member Avatar for freedomflyer

Earlier on, in [URL="http://www.daniweb.com/software-development/java/threads/412571"]this thread[/URL] my question was answered about how to add objects of a custom class I called State into a HashSet which was a value for a key in a HashMap. [CODE]Map<String, HashSet<State>> mapping = new HashMap<String, HashSet<State>>();[/CODE] However, I need to ensure that there are only …

Member Avatar for JamesCherrill
0
339
Member Avatar for krishnisilva
Member Avatar for krishnisilva
0
91
Member Avatar for Skyelher

[CODE]TreeSet goodWords = new TreeSet(); ... Iterator iterGoodWords = goodWords.iterator(); while (iterGoodWords.hasnext()) { String word = iterGoodWords.next(); System.out.println(word); }[/CODE] Tell me, why doesn’t that print anything even if there are some items in the goodWords collection? I know there are items in the set because when I check the size, …

Member Avatar for Skyelher
0
168

The End.