![]() The pop-up dialog that appears shows all the implicit methods that are available, including capitalize and many others. The second variant takes locale as an argument to be used while converting into lower case. In this tutorial, we’ll cover the toUpperCase and toLowerCase methods included in the Java String class. This is equivalent to calling toLowerCase (Locale.getDefault ()). on the next line of the editor and wait for the code assist dialog to come up (or press Ctrl-Space to display it). The first variant converts all of the characters in this String to lower case using the rules of the given Locale. In the following Java example program we learn how to use the Ascii.toLowerCase() method to convert a ASCII String to lowercase. Note: The toUpperCase() method converts a string to upper case letters. Using Eclipse with the Scala IDE plug-in, create a String like this: Java String toLowerCase() Method The toLowerCase() method converts a string to lower case letters. At the time of this writing you can’t see that the capitalize method is available on a String in the REPL, but you can see it in Eclipse. The important thing for you, the developer, is that you can tell which methods are available on a given object. ![]() With the transparency of the Scala implicit conversion approach, it appears that all three of these methods are in the Java String class, but the reality is that the toUpperCase and toLowerCase methods are on the Java String class, but the capitalize method comes from the Scala StringLike class. To capitalize the first character of a string, use the capitalize method, which appears to be on the String class: To convert a String to uppercase or lowercase, use the toUpperCase and toLowerCase methods: Scala String FAQ: How do I convert a String to uppercase or lowercase, or capitalize the first character in the string? Solution show more info on classes/objects in repl.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |