Re: question
- From: Daniel Moyne <dmoyne@xxxxxxxxxx>
- Date: Fri, 28 Sep 2007 10:25:36 +0200
Lew wrote:
Lew wrote:Lew to close the topics I will check for List substitution instead of
And you haven't answered why the map is
Map <Integer, ArrayList <<String>>
instead of
Map <Integer, List <Integer>>
. Why is it so necessary to store Strings in the List, and ArrayLists
in the Map?
Daniel Moyne wrote:
Again Lew the code provided he is not the whyole code of my application ;
it
is only somehow just alike to clearly expose my problem which was
successful done as the readers have provided the fix ; in this context
the whole code was not relevant ; in my acctual application I am reading
strings in a text file line by line ; each line contains strings
separated by coma ; when I read the file I store the strings in an
ArrayList and this ArrayList as the value of the map record with the line
number as the key.
This does not explain why the choice of ArrayList as the generic type
instead of List.
I store the strings for later process that I do not want to initiate
unless whole data of my file is proved to be correct (data is supposed to
have some particular meaning) ; if the data is ok then I proceed by
iterating the map basically loop 2 of my example.
Daniel.
Your explanation doesn't cover why you need ArrayList specifically, as
opposed
to using List as the compile-time type. Usually it's better to declare
variables as the interface type rather than a specific implementation.
Likewise, it's often easier to use Integer in a collection instead of
incurring the overhead of conversion to String, if the item being stored
is an integer, as it was in your example.
Obviously my question doesn't pertain to "the whole code of [your]
application" but to the specific examples that you posted. I am not
curious about your application, only about the practices you showed us.
I was curious why you were deviating from those practices, is all. You
don't have to explain, but I am curious still.
ArrayList in my application.
Daniel.
--
Daniel Moyne
(Nulix)---------------------------------------------------------
Distribution : Ubuntu Feisty \\|||// Machine : x86_64
kernel 2.6.20-16-generic / --- \ ATI Radeon X300
KDE 3.5.7 (' o-o ')
----------------------------------------oOO-(_)-OOo--------------------------
.
- References:
- [Map<Integer,ArrayList<String>>]question
- From: Daniel Moyne
- Re: question
- From: Peter F
- Re: question
- From: Daniel Moyne
- Re: question
- From: Peter Fourneau
- Re: question
- From: Daniel Moyne
- Re: question
- From: Lew
- Re: question
- From: Daniel Moyne
- Re: question
- From: Lew
- Re: question
- From: Daniel Moyne
- Re: question
- From: Lew
- [Map<Integer,ArrayList<String>>]question
- Prev by Date: Re: encrypted source file support in jdk?
- Next by Date: Re: encrypted source file support in jdk?
- Previous by thread: Re: question
- Next by thread: Re: question
- Index(es):
Relevant Pages
|