Browsing 7239 questions and answers with Jon Skeet
Ick - what a horrible format. I'd probably do something like: var list = doc.Descendants("Name").Select(MakeBreakfast).ToList(); ... static Breakfast MakeBreakfast(XElement nameElement) { string name = (string) nameElement; var... more 6/25/2015 11:37:18 AM
You don't need to set the time zone - it's default by default, as it were. And calling setTimeInMillis twice is pointless. So just: Calendar calendar = calendar.getInstance(); calendar.setTimeInMillis(unixTimestamp * 1000L); int hour =... more 6/25/2015 5:50:42 AM
Why Java is comparing (this == another String) inside equalsIgnoreCase method for checking a string insensitive? It's an optimization. If the reference passed in is exactly the same as this, then equals must return true, but we don't... more 6/25/2015 5:39:01 AM
Basically, you shouldn't be converting the values to strings and back in the first place. Wherever possible, avoid string conversions unless that's an essential part of what you're trying to do. In your case, you're really interested in... more 6/24/2015 8:06:10 PM
Well, you could use reflection to access the stack trace - but that's slow, and in some cases I wouldn't be surprised if the JIT skipped some stack frames due to inlining. One option is to make the methods internal, and only include the... more 6/24/2015 7:57:47 PM
The object is instantiated here: public static displayObject **ob1**, ob2, ob3; No, that's not instantiating anything. It's declaring a variable, but it's just got its default value of null. At some point you need to assign a... more 6/24/2015 7:42:26 PM
The problem is in your shuffling code: for (int i = 0; i < deck.length; i++) { int r = i + (int)(Math.random() * (N-1)); String t = deck[i]; deck[i] = deck[r]; deck[r] = t; } There's no guarantee that r will be in... more 6/24/2015 12:24:51 PM
This: var xyz = 10 < 11 ? 12 : 5 < 21 ? getValue() : 15; is treated as: var xyz = 10 < 11 ? 12 : (5 < 21 ? getValue() : 15); So we have a conditional expression with: Condition: 10 < 11 First branch: 12 Second... more 6/24/2015 6:02:57 AM
Judging by the documentation, you want: DateTime::createFromFormat('Y-m-d g:i a', $dateString, $dtUtc) Note that Y is "4 digit year", m is "zero-padded month", d is "zero-padded day", and g is "zero-padded hour". Admittedly it's quite... more 6/23/2015 5:51:05 PM
Assuming you can reposition the stream whenever you want, you can simply read bytes while the top two bits are "10". So something like: // InputStream doesn't actually have a seek method, but I'll assume you're using // a subclass which... more 6/23/2015 4:25:08 PM