不兼容的类型:java.lang.String无法转换为int

不兼容的类型:java.lang.String无法转换为int,java,Java,您可以调用bot.getSpecificState(bot.getCurrentState())bot.getSpecificState()需要一个int参数,但bot.getCurrentState()返回一个字符串。Java抱怨,因为传递的String与预期的int不兼容。类R2JCD2具有方法getSpecificState,该方法可能预期一个int参数,而您似乎在传递一个字符串参数,即同一类的方法getCurrentState的返回值。如果您提供R2JCD2类的源代码,那么我们可以确定。

您可以调用
bot.getSpecificState(bot.getCurrentState())
bot.getSpecificState()
需要一个
int
参数,但
bot.getCurrentState()
返回一个
字符串。Java抱怨,因为传递的
String
与预期的
int
不兼容。类R2JCD2具有方法getSpecificState,该方法可能预期一个int参数,而您似乎在传递一个字符串参数,即同一类的方法getCurrentState的返回值。如果您提供R2JCD2类的源代码,那么我们可以确定。

请参阅。您发布的代码不完整。错误似乎来自
R2JCD2
类,请向我们展示该类。getCurrentState方法在哪里?问题可能出在
bot.getSpecificState(bot.getCurrentState())
bot.getCurrentState()
返回什么类型,以及
bot.getSpecificState()
期望返回什么类型?如果可以避免,请不要附加这样的字符串。格式化字符串。
/**
* this is from the r2j class
*/
public String getCurrentState() {
    trace("getCurrentState() starts... ...and ends with value " + currentState + ", " + STATES[currentState]);
    return currentState + ", " + STATES[currentState];
}


/**
 *  provide the identity of the specified state
 *  @return which state is of a given number
 */
public String getSpecificState(int stateNum) {
    trace("getSpecificState() starts... ...and ends with value " + stateNum + ", " + STATES[stateNum]);
    return stateNum + ", " + STATES[stateNum];
}