M
Man Alive
I receive string in a method that always have at least one comma in it:
example:
1) california,sacramento
2)newyork,albany
I need to only extract the first part of the string; i.e. the string
portion before the comma: california, newyork
Currently, it is coded like this (stringName is the string being examined):
int commaLocation = stringName.indexOf(",");
int stringLengthBeforeComma = (stringName.length() - (commaLocation
+1));
System.out.Println("Part of String before comma: "
+stringName.substring(0,stringLengthBeforeComma));
example:
1) california,sacramento
2)newyork,albany
I need to only extract the first part of the string; i.e. the string
portion before the comma: california, newyork
Currently, it is coded like this (stringName is the string being examined):
int commaLocation = stringName.indexOf(",");
int stringLengthBeforeComma = (stringName.length() - (commaLocation
+1));
System.out.Println("Part of String before comma: "
+stringName.substring(0,stringLengthBeforeComma));