I use a hashMap to store data (certificate details) which is read from a file.
The key and value is stored in the hashMap but after calling the put method, ALL values have the value of the last added entry.
I guess it is also related to
[hashmap.get() returning wrong values even though they are all correct in the map](https://stackoverflow.com/questions/23965046/hashmap-get-returning-wrong-values-even-though-they-are-all-correct-in-the-map)
but I don't see my error:

```
HashMap<String, String[]> certDataMap = new HashMap<String, String[]>();
    String line="";
    String bankName = "", validTill = "", fingerPrint = "";
    File certDat = new File(certDataFile);
    int cntEntries=0;
    String[] data = {"dummy", "dummy"};

    if (certDat.exists()) {
        try {
            Scanner scanner = new Scanner(certDat);
            while (scanner.hasNextLine()) {
                line=scanner.nextLine();
                bankName=line.split("\\|")[0];
                validTill=line.split("\\|")[1];
                fingerPrint=line.split("\\|")[2];
                logger.debug("line: {} bankName: {} validTill: {} fingerPrint: {}",line, bankName, validTill, fingerPrint);
                data[0]=validTill;
                data[1]=fingerPrint;
                certDataMap.put(bankName, data);
                debugCertMap();
                cntEntries++;
            }
            scanner.close();
            logger.debug("{} read from {}", cntEntries, certDataFile);
        } catch (IOException e) {
            logger.error(certDataFile,e);
        }
    } else
        logger.error(certDataFile+" not found! New file will be created if certificates were downloaded");

```

The problem was the declaration of string array data outside the loop as mentioned by Jonathan:

```
        while (scanner.hasNextLine()) {
            line=scanner.nextLine();
            bankName=line.split("\\|")[0];
            validTill=line.split("\\|")[1];
            fingerPrint=line.split("\\|")[2];
            logger.debug("line: {} bankName: {} validTill: {} fingerPrint: {}",line, bankName, validTill, fingerPrint);
            String[] data = {validTill, fingerPrint};
            certDataMap.put(bankName, data);
            debugCertMap();
            cntEntries++;

```