Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > Java

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-02-2009, 07:38 PM
gaurav_kl gaurav_kl is offline
Registered User
 
Join Date: Jan 2008
Posts: 18
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);
}
Reply With Quote
  #2  
Old 11-03-2009, 08:23 AM
nspils nspils is offline
Senior Member
 
Join Date: Dec 2004
Location: San Bernardino County, California
Posts: 1,455
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.
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT -4. The time now is 01:52 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.