What's the difference between Character.toUpperCase() and Character.toTitleCase()

前端 未结 2 1924
再見小時候
再見小時候 2021-02-19 21:16

I was refactoring some of my old code and then I found out that I\'d used Character.toTitleCase() method at some point and couldn\'t help myself wondering if

相关标签:
2条回答
  • 2021-02-19 22:20

    Standard ASCII characters are so boring! Here's something more exciting:

    System.out.println(Character.toTitleCase('dz'));  // Dz
    System.out.println(Character.toUpperCase('dz'));  // DZ
    

    Live demo.

    0 讨论(0)
  • 2021-02-19 22:23

    I don't really see any "real" differences here and I think it's best not to overthink small details. I wanna point out this only line here which should help with the "issue" here.

    In general, String.toUpperCase() should be used to map characters to uppercase. String case mapping methods have several benefits over Character case mapping methods.

    Documentation String.toUpperCase(): https://www.w3schools.com/jsref/jsref_touppercase.asp

    Someone else should comment if they have more inside information.

    0 讨论(0)
提交回复
热议问题