Java: Cannot find symbol error on Map, HashMap

Lasse A Karlsen picture Lasse A Karlsen · Oct 23, 2011 · Viewed 20.6k times · Source

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?

Answer

Kal picture Kal · Oct 23, 2011

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