Browsing 7239 questions and answers with Jon Skeet
I think you should redesign getComponent to take a Class<? extends Component> rather than a Component. Then you can use isInstance: public Component getComponent(Class<? extends Component> componentClass) { for (Component... more 9/19/2013 7:39:44 AM
It seems to me that you're getting confused between a variable being declared final, and it being a constant. The compiler doesn't replace all references to local variables with a constant - but when the instance of the anonymous class is... more 9/19/2013 7:19:02 AM
In java, to achieve the above, I have to do : s.toCharArray(); Not really. You can use charAt instead: char c = s.charAt(i); Basically, C++ allows user-defined operators - Java doesn't. So the String class doesn't expose any... more 9/19/2013 7:02:36 AM
Is this because of decimal number that can't be represent exactly in base 2 binary format? Yes. Basically, 5.4f and 5.4d are not the same, because neither of them are exact representations of 5.4. 5.5f and 5.5d are the same because... more 9/19/2013 6:55:47 AM
No, they're not. Consider this: Map<String, List<String>> keyToGroup = new HashMap<String, ArrayList<String>>(); keyToGroup.put("foo", new LinkedList<String>()); The second line is fine, because a... more 9/19/2013 6:33:09 AM
You've got a List<Order> - that means you know the count, and the GetRange method. var allOrders = BuildOrders(); // Take at most 12, but don't try to take more orders than actually exist! int rangeCount = Math.Min(12,... more 9/19/2013 6:23:52 AM
Your "encrypted text" is actually base64 text. I suspect that if you convert that into non-base64 data first, you should be fine. If you've already got it as a string, that's as simple as: byte[] binaryData =... more 9/18/2013 5:51:18 PM
Error is an unchecked exception. Exception is a checked exception. It's as simple as that. So it should be reasonable to have code like this: Supertest x = new test(); x.amethod(10, "foo"); ... but test.amethod() tries to impose a... more 9/18/2013 5:27:45 PM
(This answer doesn't actually explain your NullReferenceException - but it gives an alternative approach.) Given that you're checking for an exact date wouldn't it be easiest just to format myDate as yyyyMMdd before the query, and then... more 9/18/2013 4:13:59 PM
But this wondered me, can someone explain what it is about? Sure - the ; is just an empty statement, and it's fine to have a block with no if. For example, this is valid: if (i == 0) System.out.println("i was... more 9/18/2013 3:46:21 PM