Java – why doesn’t implicit conversion happen here?

I'm looking to convert a char array to a set of characters

Logically, if I write something like how to convert an array to a set in Java instead of using built-in functions, it will work But with built - in generic functions, it won't

Why not convert string arrays to characters?

As a follow - up answer (thanks btw) I want a simple example. I mean, why does the first line implicitly project, but the second line doesn't?

My understanding is that the role [] on the right hand side is indistinguishable

Solution

Because mystring Tochararray() will return a character [], which is not character [] You can verify it through this simple test: @ h_ 301_ 4@char [] a = { 'a' }; Character[] b = { 'b' }; a = b; // doesn't work,because char[] is not a Character[]

Character [] characterArray = {‘s’,’t’,’r’,’i’,’n’,’g’}; But it complies with collections Addall (...), because when the array is initialized, each value is automatically loaded from character to character

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>