Browsing 7239 questions and answers with Jon Skeet
On line 599 this code is instantiating the AbstractSet class. How is this possible? Via an anonymous inner class. It's creating a concrete (but unnamed) subclass of AbstractSet. You can do the same for interfaces. For... more 11/30/2013 10:34:00 PM
This is the problem: int count = inputStream.read(); while (count != -1) { You're consuming a byte and then ignoring it. That means the next value you read (the size) will be incorrect. You need a different way of telling whether you're... more 11/30/2013 2:46:26 PM
I believe the point is that this would be a type where referenceField was guaranteed to be non-null, e.g. it's checked in the constructor. Compare this with nullableField, where the nullity is checked as part of equals. more 11/30/2013 2:38:31 PM
What am I doing wrong Well, you're building your SQL statement by concatenating values. That leads to SQL injection attacks - amongst other issues. Fortunately, that hasn't actually created a problem just yet - because you're never... more 11/29/2013 10:06:01 PM
This loop: for(int b:a) { a1=b; } just repeatedly assigns the value of b to a1 - so yes, when the loop has finished, a1 will have the value of the last value in a. If you want to print out the values, you need to put the output in... more 11/29/2013 10:01:53 PM
Inside the database it has rhis format: No, inside the database it will be stored in some binary format. Fundamentally, it's a date - it's not in any particular format, any more than a number is stored in decimal or hex... it's just a... more 11/29/2013 10:00:20 PM
The problem is that you've got SQL like this: UDPATE Buyer SET Name = craigs WHERE idBuer in (Whatever) That's trying to copy the value from a column named "craigs". Now you could just add apostrophes - but don't. Instead, use... more 11/29/2013 7:13:51 PM
You're trying to use a statement other than a declaration directly inside the class - rather than within a method. When did you expect the method to get called? Basically all you can have directly within a type is a bunch of declarations... more 11/29/2013 5:10:35 PM
The simplest approach would probably be to use LINQ combined with File.ReadLines: string line = File.ReadLines("foo.txt").ElementAt(6); // 0-based You could use File.ReadAllLines instead, but that would read the whole file even if you... more 11/29/2013 2:03:00 PM
One example (and this is by no means the only one) would be if the signature of a method in a library changes, in a compatible way. For example, consider: // Library.java v1 public class Library { public static void print(String foo)... more 11/29/2013 1:54:39 PM