This is a baseline tagger coed I have written.  How can I optimize this code?public class Tagger {private ArrayList<List> copyTagsList = new ArrayList<List>();public Tagger(WordChecker tagsList){    for(int i =0; i<tagsList.getCheckedTags().size();i++){    copyTagsList.add(i,tagsList.getCheckedTags().get(i));    copyTagsList.get(i).set(1,0);    }}public void extractTag(String word, ArrayList<ArrayList> trainList){int freq = 0;ArrayList<List> tagFreqOfWord = new ArrayList<List>();System.out.println(word);for(ArrayList wordState: trainList){               if (word.equals(wordState.get(1)))    {        freq+=1;        if (tagFreqOfWord.size() == 0)        {            for (int i = 0 ; i<copyTagsList.size();i++)            {                if (((String)wordState.get(4)).equalsIgnoreCase((String)copyTagsList.get(i).get(0)))                {                    tagFreqOfWord.add(copyTagsList.get(i));                    tagFreqOfWord.get(0).set(1, (int)1);                    break;                }            }        }        else         {            Boolean exist= false;            for (List j :tagFreqOfWord)            {                if (((String)wordState.get(4)).equalsIgnoreCase((String)j.get(0)))                {                    int var = (int)tagFreqOfWord.get(tagFreqOfWord.indexOf(j)).get(1);                    var+=1;                    tagFreqOfWord.get(tagFreqOfWord.indexOf(j)).set(1,var);                    exist = true;                    break;                }            }                       if (!exist)            {                List newTag = new ArrayList();                newTag.add(wordState.get(4));                newTag.add(1, 1);;                tagFreqOfWord.add(newTag);            }                               }    }}System.out.println(tagFreqOfWord);  }           }Confusion matrix (Part of AccuracyChecker class):public ArrayList<List> createConfusionMatrix(WordChecker checkedTagsList,    ArrayList<ArrayList> listOfWords){//BeanComparator fieldComparator = new BeanComparator();//Collections.sort(checkedTagsList, fieldComparator);int distinctTagsSize = correctTags.size();for(int i=0; i <distinctTagsSize;i++){    List<Integer> list = new ArrayList<Integer>();    confusionMatrix.add(i, list);;    for(int j=0;j<distinctTagsSize; j++ ){        confusionMatrix.get(i).add(j, 0);        if (i == j)            confusionMatrix.get(i).set(j, checkedTagsList.getCheckedTags().get(i).get(1));    }}for(int i=0; i <distinctTagsSize;i++){    for(int j=0;j<listOfWords.size();j++){            if (((String)correctTags.get(i).get(0)).equalsIgnoreCase((String)listOfWords.get(j).get(4))){                if(!((String)listOfWords.get(j).get(5)).equalsIgnoreCase((String)listOfWords.get(j).get(4))){                    for (List m: correctTags){                        if(((String)listOfWords.get(j).get(5)).equalsIgnoreCase((String)m.get(0))){                            int freq= (int)confusionMatrix.get(i).get(correctTags.indexOf(m));                            freq+=1;                            confusionMatrix.get(i).set(correctTags.indexOf(m),freq);                        }                    }                }        }    }}return confusionMatrix;}Do you think using 2D ArrayList is better?
Baseline tagger
java;optimization