There is problem of class casting. Please tell me how to cast this. I want to this ArrayList<CharSequence> in my CharSequence[] named Contacts.
java.lang.ClassCastException (in Android):
CharSequence[] Contacts;
List<CharSequence> contacts = new ArrayList<CharSequence>();
Contacts = (CharSequence[]) contacts.toArray();
for(CharSequence p : contacts) {
Log.i("log_tag", "AAAAAAAAAAAAAAAAAAA" + p);
}
Try this:
Although, I would advise you to rename
Contactsto something else, perhapscontactsArray. Two reasons for this: 1) Java variable names generally start with a lower-case letter. 2) You have another variable namedcontacts, defining a second to beContactswill make the code much harder to read and understand since the two names differ only by the case of the first letter.Relevant documentation:
toArray