簡體   English   中英

如何將對象轉換為Arraylist

[英]How to cast an Object to Arraylist

我需要將一個對象強制轉換為Arraylist:

<% Arraylist<Products> mypr = sesion.getAttribute("products");  %>
            <table class="table table-condensed">
                <tr>
                    <th>Id</th>
                    <th>Category</th>
                    <th>Model</th>
                    <th>Stock</th>
                    <th>Price</th>
                </tr>
                <%
                    for (Products xx : mypr) {
                        out.println(xx.toString() + "<br>");
                    }
                %>

假設它是ArrayList ,則可以對其進行ArrayList (我建議使用類似List接口)

List<Products> mypr = (List<Products>) sesion.getAttribute("products");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM