valueOf()的问题,在Java中将char转换为Character
我试图在将字符推入堆栈之前将其转换为字符,但收到“找不到符号错误”,我不知道问题可能是什么。这就是我将字符传递到堆栈的方式:
stack.push(valueOf(in));
其中“in”是一个字符。
I'm trying to convert a char to Character before it gets pushed on a stack but get a "cannot find symbol error", I don't see what the problem might be. This is how I pass the char to the stack:
stack.push(valueOf(in));
Where 'in' is a char.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
valueOf
是Character
等的类方法。你不能只是在没有类的情况下调用它来挂起它。您真正要寻找的是
Character.valueOf(in)
或new Character(in)
。valueOf
is a class method ofCharacter
, among others. You can't just call it without a class to hang it off.What you're really looking for is
Character.valueOf(in)
ornew Character(in)
.您正在寻找:
You are looking for:
我希望,
valueOf(char c)
是在您进行该调用的同一个类中定义的...;)I hope,
valueOf(char c)
is defined in the same class where you have that call ... ;)