java字符串反转函数reverse()的使用

		StringBuffer result = new StringBuffer();
        int n = s.length();
        for (int i = 0; i < n; i++) {
            char temp = s.charAt(i);
            if (Character.isLetterOrDigit(temp)) {
                result.append(Character.toLowerCase(temp));
            }
        }
        StringBuffer war = new StringBuffer();
        war = result.reverse();
        StringBuffer result1 = new StringBuffer(result).reverse();
        System.out.println("result     " + result);
        System.out.println("result1    " + result1);
        System.out.println("war        " + war);

结果
在这里插入图片描述

你可能感兴趣的:(Java,java)