public static String convertToUnderscore(String camelCase) {

        return camelCase.replaceAll(
                "([a-z])([A-Z]+)",
                "$1_$2"
        ).toLowerCase();

}

 public static void main(String[] args) {

        String camelCase = "ktCollectType";
        String underscore = convertToUnderscore(camelCase);

         System.out.println(underscore); // 输出: kt_collect_type

}

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部