[Solved] How to resolve ClassCastException: java.lang.String cannot be cast exception


You are trying to change List<String> to List<tcmb> and problem lies here

public static List<tcmb> getList(Activity a){

    // your code
    // 

    List<String> itemList = new ArrayList<String>();
    itemList.addAll(Arrays.asList(itemWords));
    dovizList = (List)itemsList;
    Log.d(TAG, "getValuestcmb: " + dovizList.size());

    return dovizList;

Also, I don’t understand, what exactly you are trying to achieve here.

List<String> itemsList = new ArrayList<String>();
dovizList = (List)itemsList;

But, as per code shared, you need to change

List<String> itemsList = new ArrayList<String>();

to

List<tcmb> itemsList = new ArrayList<tcmb>();

And, you don’t need

dovizList = (List)itemsList;

5

solved How to resolve ClassCastException: java.lang.String cannot be cast exception