oadams oadams - 2 months ago 10
Java Question

toLowerCase(char) method?

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.

Answer

toLowerCase is a static method, as such you need to qualify it with the class it belongs to, as

Character.toLowerCase(c);
Comments