Faisal Fuad wrote:
Compiler is showing red under myArrayList in the above for loop....and saying "Type mismatch: cannot convert from element type Object to String"
You didn't say which occurrence of myArrayList it's complaining about, but I'm feeling generous so I'll break out my crystal ball and predict that it's this one:
Since you didn't use generics to say that it's a list of Strings, i.e.:
the compiler takes it as a list of Object, so an Iterator (which is what the foreach loop uses) will give you back objects.
You have to either use generics, or cast in your loop.
Or, since your loop doesn't actually use any String-only methods, just treat them as objects throughout your loop.