you don't have to do it this way, this is typically my guideline
i normally would use a for loop with a known size and a while loop where you don't know the size until the last iteration
which is the same as I posted :)
I was writing in a simplistic form of pseudo-code, not in Java. the easiest way for him to go is a for, since he has a list and can easily determin the number of elements in it, but we can't do it all for him, now can we?
> can somebody give me some good example of how to iterate over list,
Just use an Iterator / ListIterator for iterating over a List in a implementation agnostic manner. Iterators have the benefit of being able to allow you to add / remove an element without any additional effort.
Using a simple looping construct for a LinkedList has serious performance implications since each get() walks the list till the element with the given index is found i.e. it's not a O(1) operation as in the case of an ArrayList but a O(n) operation.
Need some help with this Array. I am trying to get the sum of the even numbers and the sum of the odd numbers using a for each loop. I know the answers to what I am trying to achive are sum of even = 84 and the sum of ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...