I have a test case value of:
List<String> string = new LinkedList();
string.add("Hello"); string.add("hi"); string.add("bye");
Testing the following method:
// Will return longest length of a string within the list.
public int maxLengthOfString(List<String> listOfStrings) {
int maxLength - Integer.MIN_VALUE;
int index = 0;
if (listOfStrings != null) {
while(index < strings.size()){
if(strings.get(index).length() > maxLength){
maxLengthOfString = listOfStrings.get(index).length();
index++;
}
index++;
}
}
}
return maxLengthOfString;
I thought infection in the R.I.P. model meant that the program was put into an invalid state at some point during the execution. The list above will still skip index 1, but it's not in an invalid state because the purpose of the method is to check the longest String, and index 1 is not the longest.
My professor said that this is an infection because index 1 is skipped.
Is this an infection, in regards to the following webpage: http://ift.tt/1D8M46P
Aucun commentaire:
Enregistrer un commentaire