public class Test02 {
public static void main(String[] args) {
String property = "name";
String propertyGetMethodName = getPropertyGetMethodName(property);
System.out.println(propertyGetMethodName);
}
public static String getPropertyGetMethodName(String property) {
//1.property.substring(0, 1).toUpperCase():获取属性property的第一个字母并变成大写字母
//2.property.substring(1):获取属性property的第二个字母以后的字母
//3.用concat进行字符串的连接
return "get".concat(property.substring(0, 1).toUpperCase()).concat(property.substring(1));
}
} |
|