java - check the value of a word inside a string -
i have string
string example = "tag: id: somethingelse score: 0.8"; how can check if score higher/equal/lower 0.
by using lastindexof , substring string object, can value string.
string scorestr = example.substring(example.lastindexof("score:") + "score:".length()); double score = double.parsedouble(scorestr.trim()); now, can if...else if statement on score.
ps: if want returned float, change last line so:
float score = float.parsefloat(scorestr.trim());
Comments
Post a Comment