Hi all ,
Do we have any method in Java in String or StringUtils to remove an element from a string aray by index.
like remove(startindex,endIndex) in C#.
I looked over internet and StringUtils too,but i couldnt find any.
What would be the simplest method without adding performance -slow-down to my project to do this?
I already have lot of Stringbuilder -String conversions in my method.
LinkedList = 136,060,386
ArrayList = 19,373,657
LinkedList = 89,518,985
ArrayList = 18,704,275
- adding to the start or the end
- removing from the start or the end
- adding, removing or setting using a ListIterator
All direct element accesses will require the list to be traversed until that element is found, and that's what makes it slow if you use any indexed method.
LinkedList = 8,998,243
ArrayList = 6,915,845
LinkedList = 9,271,848
ArrayList = 6,724,540
Removing last element:
LinkedList = 9,612,391
ArrayList = 7,236,635
LinkedList = 12,784,090
ArrayList = 7,692,767
Removing first element:
(don't know why LinkedList is faster on first pass - this is consistent.
LinkedList = 9,667,259
ArrayList = 25,206,786
LinkedList = 11,939,864
ArrayList = 23,512,117
Inserting first element:
LinkedList = 9,510,338
ArrayList = 36,440,690
LinkedList = 9,834,421
ArrayList = 36,002,118
So better than ArrayLists for inserting / deleting at the start, but worse at the end.
I don't know how to test ListIterators.