英文:
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>
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论