2011-10-23 38 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