Convert String into Title Case

前端 未结 9 1308
终归单人心
终归单人心 2021-01-03 15:09

I am a beginner in Java trying to write a program to convert strings into title case. For example, if String s = \"my name is milind\", then the output should b

9条回答
  •  攒了一身酷
    2021-01-03 15:43

    You can use lamda instead-

    String titalName = Arrays.stream(names.split(" "))
                                           .map(E -> String.valueOf(E.charAt(0))+E.substring(1))
                                           .reduce(" ", String::concat);
    

提交回复
热议问题