Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

codegrepper java instanceof

if (vehicle instanceof Car) {
        Car car = (Car) vehicle;
        return car.wheelCount;
     } else if (vehicle instanceof Bike) {
          Bike bike = (Bike) vehicle;
         return bike.numberOfWheels;
     } else {
         throw new IllegalArgumentException("Unrecognized vehicle");
     }
Source by tedblob.com #
 
PREVIOUS NEXT
Tagged: #codegrepper #java #instanceof
ADD COMMENT
Topic
Name
8+6 =