Browsing 7239 questions and answers with Jon Skeet
Yes, it's possible as a sequence of steps: Convert the string to binary form, e.g. using UTF-8 Compress the binary data Encode the binary data back as text, e.g. using base64. Do not try to "decode" it using a text encoding like base64;... more 9/11/2014 1:25:44 AM
Why would this throw error? Because you're casting an object of type Person to Doctor. The value of p is a reference to an instance of Person, not to an instance of Doctor, therefore the cast fails. If you had: Person p = new... more 9/11/2014 1:20:52 AM
Without boxing - using just char - you'd be fine. Likewise if you use equals instead of ==, you'd be fine. The problem is that you're comparing references for boxed values using ==, which just checks for reference identity. You're seeing a... more 9/10/2014 4:49:33 PM
You've got two calls to System.out.println(a). You'll find it much easier to understand if you differentiate between them: public static void printNum(int a) { System.out.println("Before recursion: " + a); if(a <= 3) { ... more 9/10/2014 3:52:41 PM
When each Object is created JVM calculate its hashcode and put it in bucket or When Hashmap put() method is called then only JVM uses key Object to calculate hashcode ? It only calls hashCode() when it needs to - in this case when you... more 9/10/2014 1:55:23 PM
It's an argument which has some merit, but in lots of cases the problems can be avoided: If you control your code and can easily update it if necessary, then you can easily write unit tests to detect the problem and correct it if it... more 9/10/2014 1:12:52 PM
No, System.currentTimeMillis() returns the number of elapsed milliseconds since the Unix epoch (midnight at the start of January 1st 1970, UTC). This does not depend on your local time zone at all. In other words, if you call it once per... more 9/10/2014 1:00:38 PM
The documentation is fairly clear on this: This method creates a new directory with the name specified by destDirName and moves the contents of sourceDirName to the newly created destination directory. If you try to move a directory to... more 9/10/2014 12:16:14 PM
You should create an instance of the property's real type, if you know it really will be a List<T> for some T (rather than an interface, for example). You can then cast to IList and add the values to that, without knowing the actual... more 9/10/2014 4:09:30 AM
You have to finish the opening tag of the element before you have any nested content (other elements, or text). In XML, this is fine: <x> <y /> </x> But this isn't: <x <y /> </x> This isn't... more 9/10/2014 2:54:39 AM