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?
In the above program, "Cannot find symbol" error will occur because “sum” is not declared. In order to solve the error, we need to define “int sum = n1+n2” before using the variable sum.
In JavaLanguage, if you get 'cannot resolve symbol', you have used a name that the compiler hasn't recognized. If it is a class name, the compiler cannot find the class. This means that the class has not been imported properly, the name is misspelt (including incorrect cAsE) or the class simply does not exist.
Any error that starts "cannot find symbol" means that the compiler doesn't know what that symbol (which can be a variable or a class name) refers to. In the second line of the error, where it says "symbol: class Scanner", that indicates that it doesn't know what the Scanner class is.
You're possibly compiling using Java 1.4 and using generics ( only available from 1.5 onwards ).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With