Please check the below Android
code
public void setTitles(final List<AppDataBean> appDataBeanList){
dataBeanArrayList = new ArrayList<DataBean>();
outer:for(a=0;a<appDataBeanList.size();a++)
{
appDataBeanListIndex=a;
//Get data from the Bean list
final AppDataBean appDataBean = appDataBeanList.get(a);
if (InternetConnectivity.isConnectedToInternet(context)==true){
try {
LinkReader linkReader = new LinkReader();
linkReader.onFinish(new LinkReader.OnTaskCompleted() {
@Override
public void onTaskCompleted(ArrayList<DataBean> list) {
inner:for (int i = 0; i < list.size(); i++) {
if (InternetConnectivity.isConnectedToInternet(context)== true){
//Gather all information into DataBean
DataBean dataBean = new DataBean();
dataBean.setTitle(list.get(i).getTitle());
//Add the DataBean to the bean list
dataBeanArrayList.add(dataBean);
}
if(i==4)
{
break outer;;
}
}
}
@Override
public void onError() {
}
});
}
catch(NullPointerException e)
{
e.printStackTrace();
}
}
}
}
In here,notice how I have labelled the for loops as outer
and inner
. Inside the second loop I am trying to break the outer
loop when a certain condition is met, but it is not working because it is giving the compile error "undefined label: outer
".
Why is this? I tried to wrap the outer
content with curly bracers, which then covers inner
section too, and I tried without the curly bracers, the same error.