Two ways to separate Java strings with spaces

There are two ways:

1. String str = "123 456 789 111";

String [] strArray = str.split("s");

2.String str = "123 456 789 111";

String [] strArray = str.split(" ");

3. Multiple spaces are separated no matter how many spaces there are

String str = "123 456 789 111"; String [] strArray = str.split("s+");

The above is all the content described in this article. I hope you can like it.

Please take a moment to share the article with your friends or leave comments. We will sincerely thank you for your support!

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