我尝试在IntelliJ中使用Java 12,但是当我尝试运行我的应用程序时发生错误
Error:(57, 32) java: switch expressions are a preview feature and are disabled by default.
(use --enable-preview to enable switch expressions)
我添加了应用程序配置VM选项--enable-preview但仍会出现此错误。我添加了SDK路径。谁知道我做错了什么?
List<Car> sortedCars = switch (sortType) {
case COLOR -> cars.stream().sorted(Comparator.comparing(Car::getColor)).collect(Collectors.toList());
case MILEAGE -> cars.stream().sorted(Comparator.comparing(Car::getMileage)).collect(Collectors.toList());
case MODEL -> cars.stream().sorted(Comparator.comparing(Car::getModel)).collect(Collectors.toList());
case PRICE -> cars.stream().sorted(Comparator.comparing(Car::getPrice)).collect(Collectors.toList());
};