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

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -