I have an unexpected issue when using a conditional operator in java.
The code is supposed to check if the ArrayList
contains a specific string, then it returns tru
Your List
does not contain the String
that equals "."
. You have a String that contains a .
but that is not the same thing. You can do that with String.contains(CharSequence),
public boolean isDone() {
List al = new ArrayList(); // <-- I would use the Interface type
al.add(d1.getText());
al.add(d2.getText());
al.add(d3.getText());
al.add(d4.getText());
al.add(d5.getText());
// If any String in al contains a '.' return false, else true.
for (String str : al) {
if (str.contains(".")) {
return false;
}
}
return true;
}