I am trying convert method to generic for CharSequence[] and for Set. Well I am not experienced in that.
This is the method where the second argument/return value should be generic (T). Is it possible?
private CharSequence[] remove(String string, CharSequence[] charSequences)
{
ArrayList<CharSequence> newArray = new ArrayList<CharSequence>();
int foundPlace = -1;
CharSequence[] v = charSequences;
for (int i = 0; i < v.length; i++) {
if (foundPlace != -1 && v[i].equals(string))
foundPlace = i;
else
newArray.add(v[i]);
}
return newArray.toArray(new CharSequence[newArray.size()]);
}
What I tried. Replaced everywhere where CharSequence[] occurs to T but it didn't work when I placed T in line T.length
.
More clarification (sorry). I would like to convert second argument and return value to T - so everywhere where is CharSequence[] to T.