Doug Xander wrote:i need to read a csv file using scanner
Why? That's a very bad idea and I would question that requirement. Even as an excercise it doesn't make much sense as it's far from any "real coding" - so there's no value in to try to solve some hypothetical question to come up with an idea how to solve some issue which should be prevented in the first place.
I can tell from experience: I once asked here how to parse some simple json cause existing libs failed due to the other side generates non-valid data. Simple solution: I reported it as a bug to the maintainer that his code doesn't follow standards correctly and hence produce invalid data which libs following the standard fail to parse. As my report was dropped as "not a bug" I moved on to someone else with some working code producing valid data which can be parse by existing libs.
TLDR: Before you try to solve a problem try to figure if it's actually your fault. If someone wants you to parse CSV with a java.util.Scanner it's already game over right there. Nobody does that, and nobidy even should consider it. Why bother figuring it out?
Piet Souris wrote:2D String array
There's no such thing as multi-dimensional arrays in Java, only arrays with an array as its specific type. A String isn't a 2-D String array, but an array of String arrays - an array of String. This manifests itself in such a a way that the "inner level" arrays all can have different sizes. Hence when iterating over such an array always use .length in the inner loop (or even better: foreach if possible and if you don't need an index).
As seen from a data structure view it's about equivalent to a list of lists - which doesn't make it a multi-dimensional list.