Samantha Rupasingha wrote:I'm trying to verify if all the elements in an array list are same or not. This is my code:
I think everyone else has covered it, but the basic problem you have is that the code
doesn't do what you meant it to.
And when that happens, sometimes you just have to sit down with a paper and pencil and work out what your loop will do on each iteration.
However (TIP) - DON'T use '
++' or '
--' more than once in a loop. And if you do, it should usually be
inside the '
for' part.
You also need to read Paul's second post. Is that what you want to do? If so, he's given you the solution; if not, you need to explain what you DO want to do.
Winston