how to solve java.lang.ClassCastException: java.math.BigDecimal cannot be cast to [Ljava.lang.Object; in java
<p>I'm getting values through query and next i'm trying to iterating values but is throws error</p>

<pre><code>Session session = null;
   try{
     Query qu=session.createSQLQuery("select plot_no from house_details where type='duplex'");
    List&lt;Long&gt; li =  qu.list();
    System.out.println("---li---"+li.toString());
    for (Iterator itr = li.iterator(); itr.hasNext();) {
        Object[] obj = (Object[]) itr.next();
        String plotNo = (String) obj[0];
        if(plotNo=="501" || plotNo== "520" || plotNo== "601"){
        System.out.println("---if---");
        //code here
        }
        else{
        System.out.println("---else---");
        //code here
        }
    }
 }catch(Exception e){
       e.printStackTrace();

   }finally {
       if(session!=null){
        session.close();
     }
    }
</code></pre>

<p><strong>output:</strong></p>

<pre><code>---li---[501, 0, 101, 101, 114]
java.lang.ClassCastException: java.math.BigDecimal cannot be cast to [Ljava.lang.Object;
</code></pre>

<p>what is wrong in my code. Error getting this lines</p>

<pre><code>Object[] obj = (Object[]) itr.next();
String plotNo = (String) obj[0];
</code></pre>