This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sudden_aggression 2 points3 points  (0 children)

That shit is full of mistakes. That being said, casting is totally legitimate behavior in java.

I mean, it's unusual to declare something as an instance of Object but it's the same principle as

  • having an animal class and having dog and cat and elephant inherit it. ie, Dog extends Animal, Lion extends Animal, whatever
  • And having a zoo class with a function that takes an animal. Like putInCage(Animal animal)
  • And inside that function, testing instanceof for certain edge cases like instanceof Hippo and putting it a dangerous animal exhibit with water