Reputation: 19273
I have a list of thousands of strings that may come in the form:
word
or
"more than one word"
I want to remove the "" whenever they are present, so that I can save the string to my DB.
I'm wondering which method is faster:
line.replace("\"","");
Or even, is there a better way to do this?
Upvotes: 1
Views: 124
Reputation: 97148
The second method is faster. It will perform at most one character comparison and one array copy, instead of comparing all characters in the string with the " character.
Upvotes: 1