約束不匹配錯誤:該類型是不是一個有效的替代約束不匹配錯誤:該類型是不是一個有效的替代
任務:我想存儲「宋類對象」在ImmutableSet通過播放列表類。
我有三個類。
public class ImmutableBinaryTree< T extends Comparable<T>> implements ImmutableSet<T> { }
public class Song { }
public class PlayList<T extends Comparable<T>> {
private Song songs;
ImmutableSet<Song> immutableSet; // Bound Mismatch error occurring here
這就是你的所有代碼?這似乎是缺少的東西 –
嗨。守則很長,我剛纔提到了這些課程。因爲錯誤是在通用邊界中的某個地方。 ImmutableSet是由ImmutableBinaryTree類實現的接口。公共接口ImmutableSet> { –
user3094713
您是否試圖在'ImmutableBinaryTree'中存儲'Song'? –