Browsing 7239 questions and answers with Jon Skeet
However, what does one do when there is a more complex method to test, such as perhaps one that uses numbers generated from a Random object You find a way of controlling that Random. For example, you could pass it into the method, and... more 5/22/2014 6:29:20 PM
The input string could be of varying length but the encrypted string must be a max of 15 characters and alphanumeric. This is clearly impossible. If you solved this, you would solve all possible storage concerns - after all, you'd be... more 5/22/2014 5:52:53 PM
Any ideas how you can guarantee the value passed to the task without waiting for the task to complete? Sure - just create a separate variable which isn't modified anywhere else. You can use a new scope to make that clear: long num =... more 5/22/2014 5:36:35 PM
How can i have the original value in a double variable? You can't. The closest double to your original value is exactly 38.739793110376837148578488267958164215087890625 That's being converted to "38.73979311037684" because that's the... more 5/22/2014 4:49:04 PM
You could use a ManualResetEvent instead... but I would instead encourage you to use a higher level abstraction. Consider whether your task may be appropriate for the Dataflow API - or possibly use a BlockingCollection for each listener,... more 5/22/2014 4:34:31 PM
Well you can't see MyInterface from outside the package, as you said - but MyEnum effectively has a public abstract myMethod() method, which you're able to use as a method reference. Leaving aside fancy new Java 8 features, this is valid... more 5/22/2014 3:49:05 PM
There are two fields which the identifier str can refer to - a static one inherited from Int1, and an instance one inherited from Pparent. Even though it's invalid to try to use the instance one from a static context, the name can still be... more 5/22/2014 3:10:30 PM
As you've seen, calling a method doesn't count as a constant expression. The cleaner solution (IMO) is to have a static method within your enum: // Enum renamed to comply with conventions public enum MessageType { private static... more 5/22/2014 1:52:36 PM
I can't check for null because an enum is a non-nullable value type. Any particular enum is a value type, but Enum itself isn't. (Just like ValueType isn't a value type either... every type derived from ValueType except Enum is a... more 5/22/2014 1:36:09 PM
If that value is not on database is an error. An error in terms of "my belief system about the state of the system has been violated" or "the input must be invalid somehow"? It sounds like it's more the former - so I'd throw an... more 5/22/2014 12:49:26 PM