我收到以下編譯錯誤:javac -cp "/Users/myname/Desktop/Projects/Project/target/jarname.jar" Util.java -Xlint:uncheckedUtil.java:51: error: incompatible types: inference variable R has incompatible bounds tags = Arrays.stream(tagArray).collect(Collectors.toList()); ^ equality constraints: List<String> upper bounds: ArrayList<String>,Object where R,A,T are type-variables: R extends Object declared in method <R,A>collect(Collector<? super T,A,R>) A extends Object declared in method <R,A>collect(Collector<? super T,A,R>) T extends Object declared in interface Stream1 error現在我的印象是,您應該能夠通過這種方式將所有 Stream 元素放入一個列表中。我對 Java 有點陌生......我在這里不明白什么?這是在 Util.java 中導致問題的函數:public static GoogleMerchantDetailsDto convertGoogleMerchantDetails(SqlRow row) { Array rawTagArray = (Array) row.get("tags"); ArrayList<String> tags = new ArrayList(); if (rawTagArray != null) { String[] tagArray = Util.toStringArray(rawTagArray); tags = Arrays.stream(tagArray).collect(Collectors.toList()); } String distanceFrom = String.format("%,.1f", row.getDouble("distance_from")); String latitude = String.format("%,.6f", row.getDouble("latitude")); String longitude = String.format("%,.6f", row.getDouble("longitude")); GoogleMerchantDetailsDto googleMerchant = GoogleMerchantDetailsDto.builder().withId(row.getString("id")) .withName(row.getString("name")).withTags(tags).withDistanceFrom(distanceFrom).withLatitude(latitude) .withLongitude(longitude).withIsFavorite(row.getBoolean("is_favorite")) .withWaitlist(row.getInteger("waitlist")).withAddress1(row.getString("vicinity")).build(); return googleMerchant;}
錯誤:類型不兼容:推理變量 R 具有不兼容的邊界
幕布斯6054654
2023-06-14 14:37:12