To answer this: Why did you put them in one array instead of seperating them into different ones. I thunk you should have seperated them at first and add them to the corrct array.
If you put them in one array, then you can exploit the polymorphic OO- design capabilities. Leaving the runtime engine take care of the differences using dynamic binding. Please, correct if I am wrong! Mario On Thu, Dec 31, 2009 at 1:45 AM, Stephen Hunter <[email protected]>wrote: > Why did you put them in one array instead of seperating them into > different ones. I thunk you should have seperated them at first and > add them to the corrct array. > > Now how are you tellingthe difference between the coffee and juice? > This will probably be the equation to check against in your if > statement. > > Now for the "for" loop, there is an array called a "for each" array > witch will itterate thru an array of objects. Just Google it and you > will see the syntax, it is easy to use. > > > Stephen > > > > > > > > Sent from my iPhone > > On Dec 30, 2009, at 6:36 PM, DrybLrac <[email protected]> wrote: > > > hello all I have an arraylist problem...I created a program to store > > coffee and juice objects in a arraylist bout how do I display them > > with a for loop. Inside the for loop I know I need a if statement to > > see if the current object in the for loop is coffee or juice. but > > don't know how to write it...any suggestions? > > > > -- > > To post to this group, send email to > [email protected] > > To unsubscribe from this group, send email to > [email protected]<javaprogrammingwithpassion%[email protected]> > > For more options, visit this group at > http://groups.google.com/group/javaprogrammingwithpassion?hl=en > > -- > To post to this group, send email to > [email protected] > To unsubscribe from this group, send email to > [email protected]<javaprogrammingwithpassion%[email protected]> > For more options, visit this group at > http://groups.google.com/group/javaprogrammingwithpassion?hl=en > -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en
