且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java字符串-用一个空格替换多个空格,然后根据空格将字符串拆分为数组

更新时间:2022-12-11 08:19:25

首先消除多个空格:

String after = before.trim().replaceAll(" +", " ");

然后使用split方法将字符串拆分为您的数组

Then Split the String up into your array using the split method