I'm supposed to use an instanceOf for an assignment, and it says the type is incompatible. Here is my code:
package City;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Brian
*/
public class City {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Car[] vehicle = new Car[4];
vehicle[0] = new Car("Ford", 2);
vehicle[1] = new Limo("Ford", 5, 28);
vehicle[2] = new SportsCar("Chevy", 3, "Red");
vehicle[3] = new Roadster("Ford", 3, false);
for(Car vehicles: vehicle){
System.out.println(vehicles.toString());
if(vehicles instanceOf SportsCar){
System.out.println("Yes");
}
}
}
}