Referring to a non-final variable data inside an inner class
- by shoaibmohammed
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