java - Separating a char from a String? -
i trying separate char following examples of inputs:
c450.00 c30 p100
i have char such "c" or "p" separated can work them alone, "450.00", "30", , "100" separated ints. easiest way this?
you can split string whitespace delimiter. afterwards use substring on every part of string. have c , 450.0 stings. cast second part of substring integer , done.
to split:
string[] parts = string.split(" ");
to substring:
string first = parts[0].substring(0, 1); string second = parts[0].substring(1);
Comments
Post a Comment