Browsing 7239 questions and answers with Jon Skeet
Is there a way to do a "checked cast"? Sure, although it's important to note that it doesn't really help you here, because your method is hard-coded to use B in a few places. You can perform the cast with: clazz.cast(test) ... but... more 9/24/2014 5:01:50 PM
Static methods can always call instance methods - so long as they have a reference to an instance on which to call the method. For example: public static void main(String[] args) { String foo = "hello"; ... more 9/24/2014 2:55:53 PM
From the docs of java.util.Formatter: The format specifiers for general, character, and numeric types have the following syntax: %[argument_index$][flags][width][.precision]conversion So %1$#2s means an argument_index of 1, a flags... more 9/24/2014 2:38:12 PM
Judging by comments, you're expecting that this lambda expression will only be executed once, while strTemp still has a value of null. s => strTemp == null || !strTemp.Contains(s) That's not the case. It will execute for each element... more 9/24/2014 1:56:59 PM
This is almost certainly the problem: String apiResponse = Server Response protoResponseClass.parseFrom(apiResponse.getBytes()) Protocol buffer messages are binary data. They're not text, and shouldn't be handled as text. You're taking... more 9/24/2014 6:15:56 AM
The problem has nothing to do with the parents here (and you're not doing a join anyway) - and it's not even in your second line. The problem is just that a List<FirstBar> isn't a List<Foo>, even though every FirstBar is a Foo.... more 9/24/2014 6:10:15 AM
This is the immediate problem: ')<='+CHAR(39)+@Today+CHAR(39) You're trying to use a DATETIME in string concatenation. A date isn't text - it's a date. So if you want to use it in string concatenation, you need to convert it to text... more 9/24/2014 5:59:32 AM
Well you can use Iterable.forEach: thisCollection.forEach(x -> x.setTested(true)); That's still going to iterate, of course - there's nothing you can do about that. You've got lots of objects to modify... how would you expect them to... more 9/23/2014 9:50:54 PM
Well there are types in Java which are anonymous in that you can't refer to them by name, but they have very little in common with anonymous types in C#. In Java they're anonymous inner classes, e.g. Runnable x = new Runnable() { ... more 9/23/2014 7:00:34 PM
If you want a variable which can just hold any reference value, that's easy to do: Object dogObj = new Dog(); However, if you then try to call: dogObj.bark(); ... you shouldn't be surprised that the compiler doesn't know what you're... more 9/23/2014 5:01:22 PM