2011-10-23 41 views
3

我试图运行此代码:的Java:无法在地图上找到符号错误,HashMap的

import java.util.*; 

public class NxtStart { 
    ScanReg sr = new ScanReg(); 
} 

这一直给我下面的错误:这个类中

import java.util.*; 

public class ScanReg { 
    public Map<Integer, ArrayList<Long>> scanMap = new HashMap<Integer, ArrayList<Long>>(); 
} 

.\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 

有人可以告诉我为什么吗?

+0

你没有自己的名为'java.util'的本地包吗?我会尝试导入整个类名:'import java.util.Map;',对于其他使用的util类(如HashMap)也是如此。 –

+0

没有帮助: -/ –

+0

Kal可能会对某事(1+对他!)。 –

回答

0

您可能正在使用Java 1.4编译并使用泛型(仅适用于1.5以上版本)。

+0

在这里说Java 1.7.0 .. –

+0

对不起..我不能重现这个问题。我复制了你的ScanReg.java,它编译得很好。 – Kal