角色 vs 使用数组和数组列表的 char?

huangapple go评论98阅读模式
英文:

Character vs char with arrays and array lists?

问题

为什么字符数组无效,但字符数组有效,为什么Character列表有效,但字符列表无效?这可能与基本类型与对象有关,但是否有人可以更清楚地解释一下?

英文:

Why are Character arrays not valid, but char arrays are, and why are Character lists valid, but char lists not? This probably has something to do with primitives vs objects, but can someone explain it more clearly?

答案1

得分: 2

both char[] and Character[] are perfectly valid. When it comes to generics, though, (like those in List<T>), the generic parameter must be a class and not a primitive, so you can only have List<Character>.

英文:

both char[] and Character[] are perfectly valid. When it comes to generics, though, (like those in List<T>), the generic parameter must be a class and not a primitive, so you can only have List<Character>.

huangapple
  • 本文由 发表于 2020年9月1日 04:55:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/63678065.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定