valueOf()的问题,在Java中将char转换为Character

发布于 2024-08-10 22:30:11 字数 141 浏览 2 评论 0原文

我试图在将字符推入堆栈之前将其转换为字符,但收到“找不到符号错误”,我不知道问题可能是什么。这就是我将字符传递到堆栈的方式:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

秋日私语 2024-08-17 22:30:11

valueOfCharacter 等的类方法。你不能只是在没有类的情况下调用它来挂起它。

您真正要寻找的是

Character.valueOf(in)new Character(in)

valueOf is a class method of Character, 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) or new Character(in).

请持续率性 2024-08-17 22:30:11

您正在寻找:

stack.push(Character.valueOf(in));

You are looking for:

stack.push(Character.valueOf(in));
恰似旧人归 2024-08-17 22:30:11

我希望, valueOf(char c) 是在您进行该调用的同一个类中定义的...;)

I hope, valueOf(char c) is defined in the same class where you have that call ... ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文