1. java: combined instanceof and cast? stackoverflow.com(Please no advise that I should abstract |
2. Instanceof and casting objects coderanch.comImagine 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 ... |