提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
获取设置器方法名称
//package com.nowjava; public class Main {/**nowjava**/ public static void main(String[] argv) throws Exception { String property = "nowjava.com"; System.out.println(getSetterMethodName(property)); } public static String getSetterMethodName(String property) { StringBuilder sb = new StringBuilder(); sb.append(property); if (Character.isLowerCase(sb.charAt(0))) { if (sb.length() == 1 || !Character.isUpperCase(sb.charAt(1))) { sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));