Referring to a non-final variable data inside an inner class
Posted
by shoaibmohammed
on Stack Overflow
See other posts from Stack Overflow
or by shoaibmohammed
Published on 2010-06-17T07:03:17Z
Indexed on
2010/06/17
7:13 UTC
Read the original article
Hit count: 258
Im doing a program in GWT. Here is the snippet where Im having problem
private String[] populateRSSData() {
1==>> String[] data = null;
try {
new RequestBuilder(RequestBuilder.GET,
"../database.php?action=populaterss").sendRequest(null,
new RequestCallback() {
@Override
public void onResponseReceived(Request request,
Response response) {
2==>> data=response.getText().split("~");
}
@Override
public void onError(Request request, Throwable exception) {
Window.alert(exception.getMessage());
}
});
} catch (RequestException e) {
Window.alert(e.getMessage());
}
return data;
}
Now the problem arises that I get an error that the variable 1==>>
data
should be declared final
. But if I declare it as final
then i cannot store the datas in 2==>>
The error i get
Cannot refer to a non-final variable data inside an inner class defined in a different method RSS_Manager.java
Please suggest
© Stack Overflow or respective owner