0

If just started coding 2 months ago. After learning the basics of Java, I'm getting to my own projects now.

My question. I'm reading in Excel-files from which I'm creating vocabulary-objects. Those vocabularies are getting stored in an ArrayList. I want to name my List like the file name. I know how to get my filename, not to set it as listname, though.

If it isn't possible, can anyone think of an idea how I can distinguish my lists later on?

Ecko
  • 25
  • 2
  • What do you mean you want to name your list? In what context, are you storing your list somehow like in a map? Maybe you can add some code to show us what you want to achieve? – Joakim Danielson May 27 '18 at 13:33

1 Answers1

0

You could use a map structure to store pairs : filename and the list of files.
It could look like to Map<String, List<File>> filesByFileName where the key is the filename and the value is the list of files associated to.
Note that the HashMap (common implementation of Map)doesn't maintain a specific order of the entries but others like LinkedHashMap or TreeMap do.

Here is an Oracle tutorial about the Map interface.
By the way, favor java.nio.file.Path to java.io.File as much as possible.

davidxxx
  • 125,838
  • 23
  • 214
  • 215