|
#1
|
|||
|
|||
|
is there syntax error
hi,someone plz tell if thr is any syntax error in the following code-
Code:
public LinkedList findOrdersForProduct(Product p, boolean debug) {
ArrayList l = new ArrayList();
ArrayList list = getAllOrders();
for (int i=0; i<list.size(); i++) {
Order order = (Order) list.get(0);
boolean found = false;
if (order.getProducts().size() > 0) {
for (int j=0; j<=order.getProducts().size(); j++) {
Product p2 = order.getProducts().get(j);
found = (p2 == p);
}
if (found && order != null)
l.add(order);
}
}
return new LinkedList(l);
}
|
|
#2
|
|||
|
|||
|
what does the compiler tell you?
You probably want to change the "0" in this statement to "i" Order order = (Order) list.get(0); Why not use "generics" in defining your containers? Then you will be assured that your list returned by getOrders() has only Orders as elements. Provides you automatic type checking Last edited by nspils; 11-03-2009 at 08:35 AM. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| JBOSS JTA for 2 phase commit in Distributed transactions | Amt_asc | Database | 0 | 04-03-2009 04:13 AM |
| syntax error from function in include file | larryy@indiana. | ASP.NET | 1 | 03-20-2009 02:29 PM |
| SQL Statement | shers | Database | 4 | 06-17-2006 05:01 AM |
| I can't link FreeImage to C# | mesh2005 | .NET | 1 | 03-06-2006 09:16 AM |
| Syntax Error Updating SQL Server Table | Ralf | Database | 26 | 08-08-2002 09:58 AM |