Comparing String to int JAVA -
i trying figure out how make sure string variable not have number string. cannot import anything.
i have tried
namearray[i].equalsignorecase("")) || integer.parseint(namearray[i]) >= 48 && integer.parseint(namearray[i]) < 58
but did not work.
in java 8+, might use intstream
generate range ([48, 58]
) , check if string
equal namearray
. like,
if (intstream.rangeclosed(48, 58).anymatch(x -> string.valueof(x) .equals(namearray[i]))) { }
you mention want make sure doesn't contain value - perhaps want nonematch
like
if (intstream.rangeclosed(48, 58).nonematch(x -> string.valueof(x) .equals(namearray[i]))) { }
Comments
Post a Comment