instanceof « cast « Java Data Type Q&A





1. java: combined instanceof and cast?    stackoverflow.com

(Please no advise that I should abstract X more and add another method to it.) In C++, when I have a variable x of type X* and I want to do something ...

2. Instanceof and casting objects    coderanch.com

Imagine a method that returns an java.lang.Object which is the super object of all Java objects. But lets say that this method sometimes returns an instance of a Foo object. If you want to check if the returned type is a Foo object and not just an object you could do something like: private Object getSomeObject() { ... } ... Object ...