Browsing 7239 questions and answers with Jon Skeet
The following code should print out 123123 Not necessarily. You should basically never rely on threads with no synchronization between them happening to wake up and execute in any particular order. Let's take the very first character... more 6/11/2015 1:06:20 PM
You can't, basically. Attribute values are embedded directly in the compiled assembly - they can't be determined at execution time. If you need information which is only available at execution time, you'll need a different approach which... more 6/11/2015 8:48:36 AM
Yes, that's a fairly common pattern - usually with a bunch of methods with a with prefix. Each with* method "changes" a single field, so you can have: Person jon = new Person("Jon", "Skeet"); Person holly = jon.withFirstName("Holly"); //... more 6/10/2015 5:05:22 PM
Okay, so the updated requirements are: Fetch all items Ordering is random other than the first item, which should be the last one added Firstly, get rid of your Skip call. You're not trying to skip anything. Just fetch all the products... more 6/10/2015 10:44:49 AM
This isn't how you construct an array; new Dictionary<string, int>[2]() You don't need the () at all - you're not calling a method or a constructor; you're creating an array instance. Just: new Dictionary<string,... more 6/10/2015 10:22:41 AM
Your main method has the wrong signature. To be an entry point for a Java application, it must have a single parameter of type String[] (and a void return type, and it must be public and static): public static void main(String[]... more 6/10/2015 9:36:24 AM
You're creating a single ArrayList<String>, and adding a reference to that list to your ArrayList<ArrayList<String>> several times. You need to create a new object within your loop, so that each iteration creates an... more 6/10/2015 9:30:42 AM
The Unicode escape sequences are applied earlier in the source transformation than the character literal escape sequences. Unicode escape sequences are transformed very early in the process - before any other lexing happens, including... more 6/10/2015 8:16:07 AM
As always for performance: write the simplest code you can, and test it to see whether it performs well enough. If you only need the element (and not the index) I would encourage you to use the enhanced-for loop: for (int value : array)... more 6/10/2015 6:21:57 AM
Any way to not wait and still get result? No, because there isn't a result until the task has completed. The point is that you can maintain a reference to the task, perform some other operations, and then get the result. Note that... more 6/9/2015 7:52:48 PM