Browsing 7239 questions and answers with Jon Skeet
The literal 2.7 is a double - i.e. the closest double value to 2.7. Float.valueOf("2.7") - or 2.7f, equivalently, is the closest float value to 2.7. Neither of them will be exactly 2.7 - and in this case, they're both slightly greater... more 2/23/2015 9:15:35 AM
If you actually mean "a time zone which has a permanent constant offset from UTC", that's easy: int offsetMillis = (int) TimeUnit.HOURS.toMillis(offsetHours); TimeZone zone = new SimpleTimeZone(offsetMillis, "some id"); If you mean a... more 2/23/2015 8:12:40 AM
Let's try to look at this line the same way that the compiler would: animal.dogMethod(); First, it needs to work out what animal means. That's nice and easy - it's a local variable in the current method, so it doesn't need to look... more 2/22/2015 4:31:18 PM
I believe the problem is due to your use of SimpleDateFormat - it isn't thread-safe. If you create a new SimpleDateFormat each time you need to use it, your results should be stable. (The order won't be, but that's okay.) If you possibly... more 2/22/2015 4:13:23 PM
It is JSON, just for an array. Assuming the URL always gives you back JSON, you could parse it like this (using Json.NET, which still supports .NET 2.0): using System; using Newtonsoft.Json.Linq; class Test { static void Main() ... more 2/22/2015 3:51:37 PM
StreamReader.ReadLine (and equivalently ReadLineAsync) will often read more than just a single line - it basically reads into a buffer and then interprets that buffer. That's much more efficient than reading a single byte at a time, but it... more 2/22/2015 10:08:53 AM
Yes, absolutely - it makes the nullity check safe. If you just have: // Bad code, do not use if (OnQueryComplete != null) { OnQueryComplete(this, ...); } then the last subscriber may unsubscribe between the check and the... more 2/22/2015 8:03:00 AM
You can just use one listener - the onClick method takes a View parameter, which is the view that was clicked on. You can then find out which of your buttons that was: View.OnClickListener sharedClickHandler = new View.OnClickListener()... more 2/22/2015 7:51:44 AM
If you've put the breakpoint on the last line, then when it hits, the assignment hasn't executed yet. If you put a breakpoint in the constructor body - or just step over the line - you'll find the value is assigned appropriately. (It... more 2/21/2015 9:59:50 PM
No, the behaviour you're describing in point 2 isn't what you'll see. The synchronization object is dependant on where the method is declared, not on how it's called. From JLS 8.3.4.6: For a class (static) method, the monitor... more 2/21/2015 10:10:59 AM