Browsing 7239 questions and answers with Jon Skeet
Revised answer There's time taken to load and JIT-compile the code on the first call - that's why typically benchmarks don't include the first run. (In fact, many JVMs re-JIT more and more aggressively, so the performance improves over... more 4/1/2014 1:59:01 PM
No, it's absolutely fine to have two different kinds of Fruit in a List<Fruit>. The issue comes when you've actually created a List<Banana>. For example: List<Banana> bananas = new ArrayList<>(); bananas.add(new... more 4/1/2014 1:15:39 PM
This is the problem: str.charAt(i)+count+"," That's performing a char + int conversion, which is just integer arithmetic, because + is left-associative. The resulting integer is then converted to a string when "," is concatenated with... more 4/1/2014 12:30:33 PM
Just add a field for that: public enum TaskStatus { TaskCreated(1, "Task Created"), TaskDeleted(2, "Task Deleted"); private final int value; private final String description; private TaskStatus(int value, String... more 4/1/2014 11:37:13 AM
In the below Class A isn't x a local variable too since it is in blocks({}) No. It's not in a block. It's in a class declaration, but that's not a block as such. "Block" isn't synonymous with "text in braces". To be a bit clearer,... more 4/1/2014 8:19:19 AM
The problem has nothing to do with the name of the XML file, or the code you posted. It has everything to do with the XML being invalid. XML element names can't contain spaces, so this isn't valid: <Service-1 Agent/> Instead, you... more 4/1/2014 7:47:52 AM
LINQ to XML makes this trivial - you just specify the namespace for the element, and it will include the xmlns="..." automatically. You can give it an alias, but that's slightly harder. To produce the exact document you've shown, you just... more 4/1/2014 6:14:51 AM
As i see it, the numbers are nowhere near the precision limit of the float They really are - or rather, the difference is. The exact values involved are 8.52500057220458984375 (rounded up to 8.525001 for display) and... more 4/1/2014 5:55:29 AM
I suspect this is at least one immediate problem: if (p1.getBPos().isDeparture() && p2.getBPos().isVacation()) { return SWAP_BPOS; } else if (p1.getBPos().isVacation() && p2.getBPos().isDeparture()) { return... more 3/31/2014 5:38:12 PM
Your super call is outside the method. This: public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); { ... } should be: public void onCreate(Bundle savedInstanceState) { ... more 3/31/2014 4:52:37 PM