【Java】+获取字符串首位和末位

    public static void main(String[] args) {
        String str = "[测试}";
        if (str.startsWith("[")) {
            System.out.println(String.format("首位:["));
        }
        if (str.endsWith("+")) {
            System.out.println(String.format("首位:}"));
        }
    }

 

posted @ 2020-05-12 17:26  淡怀  阅读(1767)  评论(0编辑  收藏  举报