黑马程序员技术交流社区

标题: 字符串连接的帖子 [打印本页]

作者: 永和豆浆    时间: 2016-4-21 00:43
标题: 字符串连接的帖子
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));
                                }
                        }       




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2