Java: Cannot find symbol error on Map, HashMap

20,161

You're possibly compiling using Java 1.4 and using generics ( only available from 1.5 onwards ).

Share:
20,161
Lasse A Karlsen
Author by

Lasse A Karlsen

Part-time programmer.

Updated on May 23, 2020

Comments

  • Lasse A Karlsen
    Lasse A Karlsen almost 4 years

    I'm trying to run this code:

    import java.util.*;
    
    public class ScanReg {
      public Map<Integer, ArrayList<Long>> scanMap = new HashMap<Integer, ArrayList<Long>>();
    }
    

    within this class:

    import java.util.*;
    
    public class NxtStart {
      ScanReg sr = new ScanReg();
    }
    

    This keeps giving me the following error:

    .\ScanReg.java:6: error: cannot find symbol
            public Map<Integer, ArrayList<Long>> scanMap = new HashMap<Integer, Arra
    yList<Long>>();
                   ^
      symbol:   class Map
      location: class ScanReg
    .\ScanReg.java:6: error: cannot find symbol
            public Map<Integer, ArrayList<Long>> scanMap = new HashMap<Integer, Arra
    yList<Long>>();
                                                               ^
      symbol:   class HashMap
      location: class ScanReg
    2 errors
    

    Can somebody please tell me why?