显然有一个方法接受一个char并返回一个char:)
但我似乎无法让它工作。我的代码:
import java.lang .Character;
公共类测试{
public static void main(String [] args){
char c ='A';
c = toLowerCase(c) ;
System.out.println(c);
}
}
当我编译它时,我收到以下错误:
$ javac Test.java
Test.java :6:找不到符号
符号:方法toLowerCase(char)
location:class Test
c = toLowerCase(c);
^
1 error
我做错了什么?谢谢。
解决方案toLowerCase是一种静态方法,因此您需要使用它所属的类来限定它,因为
Character.toLowerCase(C);
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.
解决方案toLowerCase is a static method, as such you need to qualify it with the class it belongs to, as
Character.toLowerCase(c);
这篇关于toLowerCase(char)方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!