1

I currently have this piece of code:

Map<Double, Character> memory = new HashMap<Double, Character>();

However it returns this error upon compiling:

GameLogic.java:5: type Map does not take parameters
Map<Double, Character> memory = new HashMap<Double, Character>();
   ^
1 error

I have no idea why its doing this as I see no reason it should after looking at other questions. It is within the 'GameLogic' class. Please could someone help.

11
  • Which Map type are you using? Commented Feb 24, 2014 at 1:20
  • possible duplicate of Creating a map in Java Commented Feb 24, 2014 at 1:21
  • HashMap?? I'm new to Java so unsure of the names and how it works. Commented Feb 24, 2014 at 1:22
  • What are the exact import statements? Commented Feb 24, 2014 at 1:22
  • 1
    @pokeairguy: it is probably causing ambiguity and preferring your self defined class over the actual one. Try it like this: java.util.Map<Double, Character> memory = new HashMap<>(); Commented Feb 24, 2014 at 1:32

2 Answers 2

2

Two possible mistakes:

  • You are using JKD 1.4
  • You imported something else than java.util.Map
Sign up to request clarification or add additional context in comments.

Comments

0

You may have imported the wrong Map class. java.util.Map takes parameters.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.