/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
ArrayList<String> packageName = new ArrayList<String>();
packageName.add("com.example.dummy");
packageName.add("edu.app.reading");
ArrayList<Integer> index = getIndex(packageName);
for (int i = 0; i < index.size(); i ++) {
System.
out.
println(index.
get(i
)); }
}
private static ArrayList<Integer> getIndex(ArrayList<String> searchName) {
ArrayList<Integer> indexList = new ArrayList<Integer>();
"com.example.appdemo", "com.example.dummy", "edu.app.reading",
"edu.app.knowledge" };
/*
* for iterating each and every item of list
*/
for (int i = 0; i < searchName.size(); i++) {
//Log.i("MISSION", "value will be: " + searchName.get(i).toString());
/*
* for searching listItem in package name array
*/
indexList.
add(Arrays.
asList(collectionData
).
indexOf(searchName.
get(i
))); /*for (int j = 0; j < collectionData.length; j++) {
indexList.add(Arrays.toList().indexOf(searchName.get(i).toString()));
break;
}*/
}
return indexList;
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCUFycmF5TGlzdDxTdHJpbmc+IHBhY2thZ2VOYW1lID0gbmV3IEFycmF5TGlzdDxTdHJpbmc+KCk7CiAgICAJcGFja2FnZU5hbWUuYWRkKCJjb20uZXhhbXBsZS5kdW1teSIpOwogICAgCXBhY2thZ2VOYW1lLmFkZCgiZWR1LmFwcC5yZWFkaW5nIik7CiAgICAJQ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