Browsing 7239 questions and answers with Jon Skeet
Just use withDayOfMonth, and lengthOfMonth(): LocalDate initial = LocalDate.of(2014, 2, 13); LocalDate start = initial.withDayOfMonth(1); LocalDate end = initial.withDayOfMonth(initial.lengthOfMonth()); more 3/6/2014 12:00:36 PM
How do I fix this without using Integer[] arr = new Integer[]{..}? You don't. This simply won't work. I was under the impression that the compiler would box my int to Integer automatically? It will, for individual int to Integer... more 3/6/2014 10:57:08 AM
Your approach to async is fundamentally broken at the moment, because you're returning the same task for all operations... and never starting it. I don't see any "infinite loop" here - I just see you blocking on a task which can never... more 3/6/2014 10:25:16 AM
In java can I be sure that a1 is always initialized before a2 ? Yes, because the specification (section 12.4.2) guarantees it (emphasis mine): Next, execute either the class variable initializers and static initializers of the... more 3/6/2014 9:02:34 AM
Assuming you're using C# 4+ and .NET 4+, you can get this to work using generic covariance: private static List<Animal> GetFilteredAnimals(string f, Func<IEnumerable<Animal>> method) A List<Cat> can't be treated... more 3/6/2014 8:55:30 AM
If you can change the class which contains these constants, it would be better to make it an enum with a value() method. Otherwise, I would suggest building a Map<Integer, String> once using reflection, and then just doing map... more 3/6/2014 8:46:29 AM
Why are you formatting a Date to a String and then parsing it again? You shouldn't need a string representation at all. Avoid string conversions as far as you can - you're not really interested in the text representation of the date;... more 3/6/2014 7:01:58 AM
Firstly, you should absolutely not do this yourself. Use an XML API - that way you can trust that to do the right thing, rather than worrying about covering corner cases etc. You generally shouldn't be trying to come up with an "escaped... more 3/5/2014 8:28:13 PM
Not without reflection, no... and I really wouldn't recommend using reflection here. (You would be very implementation-specific.) Usually you shouldn't care about which implementation of Reader is being used at all, so you wouldn't even... more 3/5/2014 6:45:43 PM
Both your use of available() and your call to read are broken. Admittedly I would have somewhat expected this to be okay for a FileInputStream (until you reach the end of the stream, at which point ignoring the return value for read could... more 3/5/2014 5:50:03 PM