导入依赖:
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.4.0</version>
</dependency>
demo:
package com.ruoyi.project.tool;
import cn.hutool.core.util.StrUtil;
public class myTest {
public static void main(String[] args) {
//java去除字符串中指定的一个或多个字符
String str = "Hello,Word";
String s = StrUtil.removeAll(str, ',', 'o');
System.out.println(s);
}
}
本文介绍如何使用Hutool库中的StrUtil方法去除字符串中的指定字符。通过一个简单示例展示了如何从字符串中移除逗号和字母'o'。
1659

被折叠的 条评论
为什么被折叠?



