How to find ArrayList containing Object
<p>I have a method from which i am returning object like</p>

<pre><code>public static Object login(DataManager dataManager, String userName, String password)       
    ArrayList&lt;LoginCredentialsBean&gt; loginCredentialsList = new ArrayList&lt;LoginCredentialsBean&gt;();       
    String authenticated = "false";     
    Connection connection = null;       
    try {           
        connection  = dataManager.getConnection();          
    } catch (Exception e) {         
         return ("Having problem in connectiong to databaste: " + e.getMessage());          
    }       
    if (connection != null) {           
         try {                                       
             ...                     
             try {                   
                 ResultSet rs = prepStatement.executeQuery();                   

                 try {                      
                     while (rs.next()) {
                         ...                             
                         loginCredentialsList.add(new LoginCredentialsBean(roleId, orgaCode, passwordExpiryDate, date, status, language));                                                          
                        authenticated = "true";                          
                     } //end of while()                                                  
                 } finally {                     
                     rs.close();                     
                 }                   
             } finally {
                 prepStatement.close();                  
             }                
             if (authenticated.equals("true")) {                     
                updateUserLogByInserting(connection, userName);                  
             }

         } catch(SQLException e) {               
             System.out.println("Could not login from dataabse:" + e.getMessage());              
         } finally {                 
             dataManager.putConnection(connection);                          
         }                  
    }       
    if (authenticated.equals("true")) {                 
        return loginCredentialsList;            
    } else {        
        return authenticated;           
    }       
} //end of login()
</code></pre>

<p>Now i am testing it like</p>

<pre><code>public static void main(String... args) {

    MoneyTreeServices moneyTreeServices = new MoneyTreeServices();

    Object result = moneyTreeServices.login("Admin", "cbas1234");       
    if (result instanceof ArrayList&lt;?&gt;) {

        System.out.println("ArrayList instance");           
    }       
    System.out.println(result);
}
</code></pre>

<p>It returns me result like</p>

<pre><code>ArrayList instance
[pk.mazars.moneyTree.bean.LoginCredentialsBean@b7ec5d]
</code></pre>

<p>I want to ask i am using condition like <code>ArrayList&lt;?&gt;</code>. How can i check that ArrayList that contain LoginCredentialsBean object. Like when i use</p>

<pre><code>if (result instanceof ArrayList&lt;LoginCredentialsBean&gt;) {

}
</code></pre>

<p>i get error that </p>

<pre><code>Can not perform instanceof check against parameterized type ArrayList&lt;LoginCredentialsBean&gt;. Use the form ArrayList&lt;?&gt;
</code></pre>

<p>I want to check instanceof ArrayList and arraylist has LoginCredentialsBean ?</p>

<p>Thank you.</p>
