A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© 永和豆浆 中级黑马   /  2016-4-21 00:43  /  292 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

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));
                                }
                        }       

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马