Let's say I have an array like this:
String[] = {
"#abc #def",
"#abc",
"#def",
"#xyz #def"
}
My question is I want to search for specific character or string like "#abc" or "a" and get their positions in the array.
Just loop through it and check each string yourself
for(int i=0; i < array.length; i++)
if(array[i].contains("#abc"))
aPosition = i;
If you want to store multiple positions, you'll need a mutable array of some sort such as a List, so instead of aPosition = i you'll have list.add(i)
Use indexOf
String[] myList = {
"#abc #def",
"#abc",
"#def",
"#xyz #def"
};
int index = myList.indexOf("#abc");
and in the index variable you become the index of the searched element in your array
you can use ArrayUtils
String[] myList = { "#abc #def", "#abc", "#def", "#xyz #def" };
int index = ArrayUtils.indexOf(myList,"#def");