Bear Bibeault wrote:Rather than an arrays (using unreadable indexes [0] and [1]), I'd use a Map.
Yes, I think that using a Map<
String, String> instead of a List<String[]> would definitely make the code much more readable and maintainable. But doesn't a Map add unnecessary overhead in this particular situation? For example, when you add an entry to a HashMap, it has to do things like create a hash of the key, put the value in the proper bucket, etc. In the situation above, we don't need any of that. All we need is a way to store is a list of String pairs that we can iterate through. We never have to retrieve individual values by calling Map.get(), making all the hashing that HashMap does a waste.