Apparently there is a method that takes a char and returns a char: http://download.oracle.com/javase/6/docs/api/java/lang/Character.html#toLowerCase(char)
But I can't seem to get it to work. My code:
import java.lang.Character;
public class Test {
public static void main(String[] args) {
char c = 'A';
c = toLowerCase(c);
System.out.println(c);
}
}
When I compile this, I get the following error:
$ javac Test.java
Test.java:6: cannot find symbol
symbol : method toLowerCase(char)
location: class Test
c = toLowerCase(c);
^
1 error
What am I doing wrong? Thanks.
The toLowerCase() method is a static method in the Character class in Java, which is used to convert a character to lowercase. The input to this function is a character. If you need to convert a string to lowercase, refer to the String. toLowerCase method.
toLowerCase(char ch) converts the character argument to lowercase using case mapping information from the UnicodeData file. Note that Character. isLowerCase(Character. toLowerCase(ch)) does not always return true for some ranges of characters, particularly those that are symbols or ideographs.
Java String toLowerCase() method is used and operated over string where we want to convert all letters to lowercase in a string. There are two types of toLowerCase() method as follows: toLowerCase() toLowerCase(Locale loc): Converts all the characters into lowercase using the rules of the given Locale.
The toLowerCase method converts a string to lowercase letters. The toLowerCase() method doesn't take in any parameters. Strings in JavaScript are immutable. The toLowerCase() method converts the string specified into a new one that consists of only lowercase letters and returns that value.
toLowerCase is a static method, as such you need to qualify it with the class it belongs to, as
Character.toLowerCase(c);
import java.lang.Character;
public class Test {
public static void main(String[] args) {
char c = 'A';
char lc = Character.toLowerCase(c);
System.out.println(lc);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With