Can we use integer as a key for the string in the HASHMAP?

If you want to use an integer as a key in a Map you'll need to use a primitive wrapper.

Here's an example of that:

Map<Integer, String> map;

Note that the following is not valid:

Map<int, String> map; // invalid

thank you bro!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.