samedi 4 avril 2015

Remove Occurance of character from String array [duplicate]


This question already has an answer here:




I have a String array containing " at start and at the end of string I wanted to remove it Below is the code i tried but its not working



String str="98900205670001613 jonh mathews -66,822.60 65,000.00 65,000.00 -1,822.60 "
String[] tokens= new String[15];
tokens=line.split("\\s+");
tokens=replace(tokens,"\"","");

static String[] replace(String[] arr, String find, String replace) {
for (int i = 0; i < arr.length; i++) {

if (arr[i] == find) {
arr[i] = replace;
}
}
return arr;

}

Aucun commentaire:

Enregistrer un commentaire