title: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.util.List
body: <p>I have a <code>List&lt;List&lt;String&gt;&gt; dataTableList</code> and I would like to get a specific list from there and put it on my <code>List&lt;String&gt; dataList</code> so that I could loop through that specific lists' value and alter it.</p>
  
  <p>However, whenever I try to do that,I always get an error of: </p>
  
  <blockquote>
    <p>java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.util.List.</p>
  </blockquote>
  
  <p>Here's a sample of how I am trying to assign a specific list from dataTableList to dataList:</p>
  
  <pre><code>//First I looped through the List of Lists and called each list fetched as dataList
  for(List&lt;String&gt; dataList : getTryLang().getDataTableList()){ 
      //then, I created an iterator to be used later when I return the List I fetched with altered value
      int iter = 0;
      //next, I created a for-loop to iterate through the values of the List the I feched
      for(int x; x &lt; dataList.size(); x++){
          //here, I formatted each value to amount or currency format.
          dataList.set(x, getDataConvert().convertAmount(dataList.get(x)));
          //finally, after I formatted everything, I returned it or set it to the specific index it's been located before
          getTryLang().getDataTableList().set(iter, dataList);
      }
      iter++;
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Here's my code and I modified some of it and didn't include some so that I could focus on expressing where the problem occurs.</p>
  
  <p>Here's my TryLang.java:</p>
  
  <pre><code>@ManagedBean
  @SessionScoped
  public class TryLang implements Serializable {
  
     public TryLang() {}
  
     //declare
     private List&lt;List&lt;String&gt;&gt; dataTableList; 
  
  
      //getter setter
      public List&lt;List&lt;String&gt;&gt; getDataTableList() {
          return dataTableList == null ? dataTableList = new ArrayList&lt;&gt;() : dataTableList;
      }
  
      public void setDataTableList(List&lt;List&lt;String&gt;&gt; dataTableList) {
          this.dataTableList = dataTableList;
      }
  }
  </code></pre>
  
  <p>Then here's my BookOfAccountsController.java:</p>
  
  <pre><code>@ManagedBean
  @RequestScoped
  public class BooksOfAccountsController implements Serializable {
  
  
      public BooksOfAccountsController() {}
  
      //declare
      @ManagedProperty(value = "#{dataConvert}")
      private DataConvert dataConvert;
      @ManagedProperty(value = "#{tryLang}")
      private TryLang tryLang;
  
      //getter setter NOTE: I wouldn't include other getter setters to shorten the code here :)
      public TryLang getTryLang() {
           return tryLang == null ? tryLang = new TryLang() : tryLang;
      }
  
      public void setTryLang(TryLang tryLang) {
           this.tryLang = tryLang;
      }
  
      //I would just go straight to the method instead
  public void runBooksOfAccounts() throws SystemException, SQLException {
     //So there are dbCons here to connect on my DB and all. And I'll just go straight on where the List&lt;List&lt;String&gt;&gt; is being set
  
    //Here's where the List&lt;List&lt;String&gt;&gt; is being set
      getTryLang().setDataTableList(getCemf().getFdemf().createEntityManager().createNativeQuery("SELECT crj.* FROM crj_rep crj").getResultList());
  
      getTryLang().setDataTableColumns(getCemf().getFdemf().createEntityManager().createNativeQuery("SELECT col.column_name FROM information_schema.columns col WHERE table_schema = 'public' AND table_name = 'crj_rep'").getResultList());
  
      for (int x = 0; x &lt; getTryLang().getDataTableColumns().size(); x++) {
          try {
  
              Integer.parseInt(getTryLang().getDataTableColumns().get(x));
  
              getTryLang().getDataTableColumns().set(x, getDataConvert().accountCodeConvert(getTryLang().getDataTableColumns().get(x)));
              //then here is where the error points at
              for (List&lt;String&gt; dataList : getTryLang().getDataTableList()) {
                  try{
                      int iter = 0;
                      dataList.set(x, getDataConvert().convertAmount(new BigDecimal(dataList.get(x))));
                      getTryLang().getDataTableList().set(iter, dataList);
                      iter++;
                  }catch(ClassCastException ne){
                      System.out.println("cannot convert " + ne);
                  }
              }
           } catch (NumberFormatException ne) {
               //print the error
           }
        }
     }
  }
  </code></pre>