Browsing 7239 questions and answers with Jon Skeet
You're using a StreamWriter. That's for text. You shouldn't be using it to copy a zip file at all. Never use any TextWriter for binary data. Next you're using StreamWriter.Write(object), which is basically going to call ToString on the... more 7/2/2014 8:36:11 PM
No, you can't. switch/case statements are for simple "this constant value maps to this set of actions; this constant value maps to this set of actions; ...". If you need more complex processing, you should just use if statements. more 7/2/2014 8:25:07 PM
Can my abstract class constructor instantiate new instances of commonly used objects? Absolutely. The constructor for an abstract class can do basically anything a normal constructor can. The only restriction is that you can only call... more 7/2/2014 8:06:49 PM
It's easiest to think of the cursor as being between two elements. So at the start, it's before dog. Calling next() returns dog, and moves it to between dog and cat, etc. You've finished iterating when the cursor is after snake. So next()... more 7/2/2014 7:58:39 PM
It's because you have a return statement in your finally block - so the IOException is not actually going to be thrown out of your getCount() method. If a finally block completes abruptly (i.e. it throws an exception or has a return... more 7/2/2014 3:03:08 PM
Look at this code within Point<T>: T obj; public double dist(T val) { return obj.distance(val); When the compiler tries to understand what this expression means: obj.distance(val) it has to resolve the distance member. If T is... more 7/2/2014 11:23:09 AM
You're still creating a private variable - it's just done for you behind the scenes by the compiler. The variable is given an "unspeakable name", ensuring you can't refer to it in source code. You're still getting all the benefits of... more 7/2/2014 6:49:42 AM
Your jar file contains source code - if you want to use a jar file as a library in a project, you need to compile the source code first, and put the class files in the jar file. For example: $ javac -d bin... more 7/2/2014 6:04:21 AM
No, you can't do that. Typically you'd do something like: private Test(int x, int y) { this.x = x; this.y = y; } public static Test fromX(int x) { return new Test(x, 0); } public static Test fromY(int y) { return new... more 7/1/2014 8:00:45 PM
You're not "declaring a string with more than one value". You're declaring several different variables. It's really important to differentiate between variables and values. So: public string x, y, z; is equivalent to: public string... more 7/1/2014 7:59:18 PM