-1

So I tried to store a big integer number in a HashMap like below:

    import java.util.*;
    public class MyClass {

        public static void main(String[] args) {
            HashMap<String, Long> phonebook = new HashMap<String, Long>();
            phonebook.put("John", 85972252904);
            Integer a = phonebook.get("John");
            System.out.println(a);
        }
    }

The code didn't work. Eclipse told me that "the literal 85972252904 of type int is out of range". So I wanna ask:

1) What is my problem here? 2) Furthermore, HashMap only accepts Classes as its parameters, and I just found out that the class "Long" is deprecated. What am I supposed to use to store a big integer as an object now?

Thanks for reading.

1 Answers1

0

Add an 'L' to the literal so it's treated as a long: 85972252904L

TrogDor
  • 984
  • 6
  • 14