提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
标准化的二传手名字
//nowjava - 时 代 Java //package com.nowjava; public class Main { public static void main(String[] argv) throws Exception { String propertyName = "nowjava.com"; System.out.println(normalizedSetterName(propertyName)); } public static String SETTER_PREFIX = "set"; public static String normalizedSetterName(String propertyName) { String propertyBaseName = normalizePropertyBaseName(propertyName); return SETTER_PREFIX + propertyBaseName; } /** * @param propertyName * @return */ private static String normalizePropertyBaseName(String propertyName) { if (propertyName == null) return null; propertyName = propertyName.trim();//from n o w j a v a . c o m if (propertyName.length() < 1)