开发者

problem with valueOf(), converting a char to Character in Java

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:

stac开发者_开发问答k.push(valueOf(in));

Where 'in' is a char.


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).


You are looking for:

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜