indexOf()的类型不兼容

3B1B支持者:

我正在用Java编写程序,但是似乎出现错误。hexnumber.indexOf(tempstring)处,它给了我错误消息“不兼容的类型”。我对此感到困惑,因为我明确地将tempstring定义为前一行的String对象。我该如何解决?

String hexnumber = "0123456789ABCDEF";
String hexsolution = "";
int remainder = newDecNumber % 16;
String tempstring = Integer.toString(remainder);
hexsolution.concat(hexnumber.indexOf(tempstring));
newDecNumber = newDecNumber /= 16;
艾伦·D·鲍尔:

tdranv的注释是正确的- String.concat()接受String参数并返回新的String。看来您的意图是:

hexsolution = hexsolution.concat(hexnumber.substring(remainder, 1));

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章