An interesting phenomenon of Java splitting strings with split

Here is a code:

OK, the final output of the above code is 2, which is no problem, but if it is written in the following way, please see:

The result output is 0. If you write it differently, please see:

The result output is 1. Well, what if I only want 2 in either case? I wrote such a conversion code:

Results:

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
分享
二维码
< <上一篇
下一篇>>