Well basically, I was coding earlier and I encountered this
for(int i = 0; i<acl.size();i++){
//System.out.println(acl.get(i));
if(acl.get(i).contains(role)){
permissions = acl.get(i).split(":");
if(permissions[operation].equals("yes")) return true;
}
}
and I was getting index out of boundary exception, but I knew that wasn't the case so I decided to use a for loop to print out the entire content of permissions. Well surprisingly it worked ... so I did this instead to fix my code because I had no better idea what is the reason for my earlier version to fail
for(int i = 0; i<acl.size();i++){
//System.out.println(acl.get(i));
if(acl.get(i).contains(role)){
permissions = acl.get(i).split(":");
for(int j = 0; j<permissions.length;j++)
if(j==operation)
//System.out.println(permissions[operation]);
if(permissions[operation].equals("yes")) return true;
}
}
I would say that the problem was that the compiler wasn't sure whether permissions would have a value at position operation? And using the loop which loops through the array(permissions is String[]) ensures that a value at position will be available if the last if statement is true. Still not sure maybe someone could give me an insight?