[英]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.