Browsing 7239 questions and answers with Jon Skeet
Firstly, I'd advise you to not use ArrayList. Use List<T> where you can, although storing different types of objects in a list is a bit of an anti-pattern to start with. Convert.ChangeType doesn't do anything for you, and you should... more 2/8/2017 7:25:33 AM
Does your User class override equalsusing just the ID? If so, you could use: if (mySet.contains(new User(1, "irrelevant")); Note that it's quite odd to have something called mySet which is actually a List rather than a Set... I'd... more 2/7/2017 9:40:38 AM
You're trying to use doc.Element("quote") - there's no such element, so that's returning null. You'd want doc.Root.Element("quote"). Next you're asking for quoteText and quoteAuthor as if they were attributes - they're not, they're... more 2/3/2017 11:37:30 AM
It sounds like you want allMatch: return skillList.stream().allMatch(s -> hasSingleSkill(s, person)); As another more general matter, any time you have condition ? true : false you can just replace that with condition So your... more 2/3/2017 9:39:39 AM
You've parsed 813588954 as a number of milliseconds - that's over 9 days, and it's being added to 2013-07-29 14:49:53. Basically, SimpleDateFormat doesn't handle parsing nanoseconds, and java.util.Date only supports millisecond precision... more 2/2/2017 10:10:02 AM
Given what you've said, you shouldn't be using class initialization for this. In particular: You want to try multiple times You want to use a checked exception Both of those are feasible, but you'll need to move the initialization into... more 2/1/2017 9:25:10 AM
assertEquals is better because it gives the unit test framework more information about what you're actually interested in. That allows it to provide better error information when the test fails. Suppose you had String a = "Hello"; String... more 2/1/2017 7:33:39 AM
You don't, basically. Expression-bodied members are only available when you have a single statement to execute. You have two in this case. I mean, you could use tuples, but I strongly advise against it: // DO NOT USE THIS CODE - IT'S... more 2/1/2017 7:27:29 AM
Why in some cases if add Period to date and remove the sane period java 8 return another date? Because that's how calendrical arithmetic works - months are uneven lengths, and it makes things tricky to say the least. You're adding... more 1/30/2017 9:33:26 PM
I believe the answer lies in the WritableByteChannel.write documentation: Unless otherwise specified, a write operation will return only after writing all of the r requested bytes. Some types of channels, depending upon their state,... more 1/30/2017 12:29:48 PM