I'm making a spreadsheet in Java.
I'd like to make a copy of the Microsoft Excel function ISLOGICAL
.
It checks whether a value is a logical value (TRUE or FALSE), and returns TRUE or FALSE.
All cells are arrays of string. This is what I have now:
public static String islogical(String[] value){
String err = "#ERROR!";
if (value.length != 1){
return err;
}
boolean a = false;
try{
a = Boolean.parseBoolean(value[0]);
}
catch(IllegalArgumentException e){return err;}
String ans = "FALSE";
if(a){
ans = "TRUE";
return ans;
}
else{
return ans;
}
}
I don't understand why, if my string value = "8>3"
, that it doesn't give me back true
. All inputs, except the string = true
, gives back false
.