I have a list which contains the Filename from a given path,
fileNamesList
and from this list i would like to create a Alphabet list
like if there are files name start with A
then add A to list and like so upto Z
and in the same way i want to create Numbers List
also from 0 to 9
All these Alphabet and Number checking is based on Starts with from the file name
.
how to do this in java.
Finally the AlphabetList will be like A B E F....Z
and the Numbers list will be 1 2 3 9
thanks
After initializing
AlphabetList
:You can do a similar thing for
NumbersList
.Alternatively:
You can use a
HashMap<Character, List<String>>
to store your lists with a character key. This could serve the same use for numbers and letters but you could create 2 maps if you for some reason want them separated.Similarly you can add logic for number as well