Re: [問題] 請問covariant是什麼意思?
※ 引述《rick1014 (hi)》之銘言:
: The problem is that arrays are covariant, so a List<String>[] is also an
: Object[], and you can use this to assign an ArrayList<Integer> into your
: array, with no error at either compile time or run time.
: 雖然這句話我大概了解是什麼意思,
: 不過不非常清楚covarint是泛指什麼意思,
: 是後半段,is-a 又為is-b的關係就是covarint的意思嗎?
正確的 covariant 的定義我說不太上來.
大概知道的是, 假如 S 是 T 的 subtype,
S[] 就會是 T[] 的 subtype. 這種就是 convariant
subtyping 的意思.
is-a 不是 abc 的 a, 是 a an 的 a.
is-a 的意思就是 "是一個"
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 202.155.236.82
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):