Can someone fix it?
Can someone tells me that why the compiler doesn't allow me to do that? I watch this from online tutorial.
Asked
Active
Viewed 38 times
-2
![](../../users/profiles/3879847.webp)
Ranjith Kumar
- 13,385
- 9
- 95
- 126
![](../../users/profiles/5978442.webp)
Josiah Wu
- 65
- 11
-
2Please don't post screenshots of code. Please post all text as text. – Mike M. Apr 11 '16 at 05:44
-
You should import the `java.lang.Object` instead of `java.util.Objects` – Ye Lin Aung Apr 11 '16 at 05:45
-
use Map
map=new...... – Ranjith Kumar Apr 11 '16 at 05:48
1 Answers
0
It's Object
not Objects
, but it's recommended to make it the specific data type you want to input in your map(Integer
in your case) and this way you can make use of compile time checking of data types instead of doing that in run time. For example, you can't make it an Integer and input anything in it except Integers.
![](../../users/profiles/790464.webp)
Ahmed Hegazy
- 11,465
- 5
- 35
- 62
-
Mmmm. Actually it's complicated. You can say that it is. All objects in java inherits from Object so they are all objects indeed. – Ahmed Hegazy Apr 11 '16 at 16:07
-