so i have an ArryList called "files" and ive created a validation method for validating if its when used you are callling on a valid index refrence:
// validation method of an ArrayList called "files"
public boolean validIndex(int index){
if(index >= 0 && index < files.size()){
return true;
}
else{
return false;
}
}
The insted of just calling on the get method i want to be able to refrence "validIndex" method when calling an on an item from the arrayList.
// Trying to make this one work:
Public void listFile(int index){
if(validindex(index) = true){
file.get(index);
}
else{
System.out.println("Index: " + index + "is not valid!");
}
}
please help
Aucun commentaire:
Enregistrer un commentaire