I have a string variable in java having value:
String result="34.1 -118.33\n<!--ABCDEFG-->";
I want my final string to contain the value:
String result="34.1 -118.33";
How can I do this? I'm new to java programming language.
Thanks,
I have a string variable in java having value:
String result="34.1 -118.33\n<!--ABCDEFG-->";
I want my final string to contain the value:
String result="34.1 -118.33";
How can I do this? I'm new to java programming language.
Thanks,
you can use StringTokenizer:
output:
You can use:
Use a
Scanner
and pass in the delimiter and the original string: