集册 Java实例教程 返回给定属性名称的设置方法名称。

返回给定属性名称的设置方法名称。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

430
返回给定属性名称的设置方法名称。
/**
来 自 时代Java公众号 - nowjava.com
**/


//package com.nowjava;


public class Main {

    /**

     * Return the setter method name for the given property name.

     *

     * @param property the property name

     * @return the setter method name for the given property name.

     */

    public static String toSetterName(String property) {

        StringBuilder buffer = new StringBuilder(property.length() + 3);


        buffer.append("set");

        buffer.append(Character.toUpperCase(property.charAt(0)));

        buffer.append(property.substring(1));


        return buffer.toString();

    }

}