最终变量解析为非最终变量 - java

时间:2016-04-30 14:26:36

标签: java rest

我有以下代码使用REST服务来获取用户凭据。

public class Login extends FragmentActivity
{
    public void invokeWS(RequestParams params){

    final ResponseObj responseObj = new ResponseObj();
    AsyncHttpClient client = new AsyncHttpClient();

    client.get("http://<ip>:<port>/RestService/login/dologin",
            params, new AsyncHttpResponseHandler() {
                @Override
                public void onSuccess(String response) {
                    responseObj.setResponse(response);
                }

                // When the response returned by REST has Http response code
                // other than '200'
                @SuppressWarnings("unused")
                public void onFailure(int statusCode, Throwable error,
                        String content) {
                    responseObj.setContent(content);
                    responseObj.setStatusCode(statusCode);
                }
            }
        );
    }
    // rest of the logic
}

然而,我得到了着名的&#34;不能引用封闭范围中定义的非最终局部变量&#34;在变量responseObj上。我的变量是最终的,因此应该是可访问的。我错过了什么?

0 个答案:

没有答案