Hashset Concatenate using Linq

I want to concatenate two hashset but when I use Linq I get an IEnumerable and not a new hashset var hashSet1 = new HashSet<string>(); hashSet1.Add("foo"); hashSet1.Add("foo1"); hashSet1.Add("foo2"); hashSet1.Add("footoexcl...
more »

2017-04-30 12:04 (1) Answers

How to count and sort repeating strings

i have got a string of names String str = "A. Walker, L. Gordon, C. Riley, L. Gordon"; I need to count name occurancies and sort the occurancies from biggest to lowest. I have done the countung part, but I also need to sort it. String[] array = ...
more »

2017-04-07 17:04 (5) Answers

Searching in two HashSets

I have this method: bool CheckIfAvailable(HashSet<int> hayStack1, HashSet<int> hayStack2, int needle) { } And I'm trying to do the following: if hayStack1 and hayStack2 are both null the method should return true, if one of them is not...
more »

2016-12-11 13:12 (2) Answers

Why HashSet is sorted?

I am learning about containers in Java and I've read recently that HashSet doesn't give the elements in order. What's interesting for Integer my randomly made HashSet is sorted. When I changed its type to Double the printed HashSet was sorted no more...
more »

2016-11-29 16:11 (2) Answers

Same Object id in Java Map

Was trying to understand the internal working of HashSet when Class objects are used as elements of the set. Here is what i have done => Code <=. Found that the Object id are same for all the values in the map. What does this mean ? Shouldn't t...
more »

2016-09-25 16:09 (2) Answers

Pretty print HashSet in Java

I could find questions closer to this one, but not exactly what i was looking for. The problem is possibly pretty simple for many experts: I have a Hashset containing my customized bean as its content: Set<TableColumnBean> mySet = new HashSet&...
more »

2016-07-29 18:07 (0) Answers