title: Why is HashMap size different than the number of lines in the file?
body: <p>Suppose I have a file that has for example data of the following kind:</p>
  
  <pre><code> info1 word1
   info2 word2
   info3 word3
   info2 word4
  </code></pre>
  
  <p>etc</p>
  
  <p>Now, I want to create a mapping function for the words in each line. So I initially read the line, split it using the space, and get the word.</p>
  
  <p>Now this word will be the value. I know that all the words are different and unique. However the information may not be unique.</p>
  
  <p>About the key, since I'm mostly interested in the information associated with each word, I just create a String for it that is essentially all the line.</p>
  
  <p>I know that the information might not be different, but the lines definitely are, since the words are definitely different.</p>
  
  <p>The file has 40000 lines, however the size of the HashMap is 38490.</p>
  
  <p>I don't understand what's happening here. Is my logic wrong?</p>
  
  <p>here is the code:</p>
  
  <pre><code>private static void loadInfo(HashMap&lt;String, String&gt; info, File File){
    try {
      BufferedReader br = new BufferedReader(new FileReader(file));
      String[] dataInLine = new String[2];
      String line = br.readLine();
      int counter = 0;
      while (line != null) {
  
        lineData = line.split("\\s+");
        info.put(lineData[1], line);
        line = br.readLine();
        counter++;
      }
      System.out.println(counter); //counter shows the correct amount of lines
      System.out.println(info.size()); //this shows less than the amount of lines
    } catch (IOException io) {
    }
  }
  </code></pre>
  
  <p>thanks in advance</p>