- package com.heima.test1;
- public class Test1 {
- /*
- * 要求首字母大写,其余字母小写
- *
- * 分析:
- * 1.先拿到首字母转换成大写
- * 2.拿到其余字母,转换成小写
- * 3.拼接
- */
- public static void main(String[] args) {
- String line = "jdasjdADJASOaNNnnas";
- //1.先拿到首字母转换成大写
- String first = line.substring(0,1).toUpperCase();
- //2.拿到其余字母,转换成小写
- String other = line.substring(1).toLowerCase();
- //3.拼接
- line = first.concat(other);
- System.out.println(line);
- }
-
- }
复制代码 |