你可以使用字符串的 replace() 方法来去除斜杠/分隔符号,并使用 trim() 方法去掉空格。下面是一个示例代码:

public class Main {
    public static void main(String[] args) {
        String str = '字符/去除/斜杆/分隔符号,并去掉空格';
        String result = str.replace('/', '').replaceAll('\s', '');
        System.out.println(result);
    }
}

输出结果为:字符去除斜杆分隔符号,并去掉空格

Java 字符串去除斜杠分隔符号和空格

原文地址: https://www.cveoy.top/t/topic/bV3t 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录