("String after conversion in Lower Case = " + inputStr.toLowerCase()) ("Please enter String to convert it into lowercase:") The last line displays the converted string in lowercase. In the next line, the input string is stored in the variable “inputStr”. After that displaying a message to enter an input sentence. In this example, the first line of the main method instantiated an object to take input from the user. Here are the following examples mentioned below: Example #1 While passing null as a locale parameter then the program will throw NullPointerException. This type of operation is known as locale-sensitive. The locale is required for the operation to perform its task. It can be set explicitly using the method setDefault(). Default Locale is set by JVM at the time of startup. getDeafult() gets the value of default Locale for this instance of the JVM. Method toLowerCase() is similar to toLowerCase(Locale.getDefault()). One of the best ways to convert the string into lowercase is using toLowerCase(). ![]() Replacing strings tolowercase can be done in multiple ways. Public String toLowerCase(Locale locale) How to Replace String to lowercase? In the following syntax, toLowerCase() method is given, which converts a string tolowercase. ![]() toLowerCase() creates a new string after converting it to lowercase characters. This method should be used carefully as it is Local sensitive otherwise HTML tags, protocol keys, programming language identifiers can generate anonymous characters. toLowerCase() uses the default parameter “Local.getDefault()” when nothing is specified as the parameter explicitly. String class in java provides a method toLowerCase() which converts all characters of the string tolowercase. ![]() Web development, programming languages, Software testing & others
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |