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
}
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » Java将驼峰命名转化为下划线命名
发表评论 取消回复