First of all your question isn’t much describe your requirement and what have you tried so far.
But assuming your question you can try as follows.
you can create a Map<Key,Value>
Integer value as a Key
and Integer List<Integer>
as Value
Map<Integer,List<Integer>> map=new HashMap<>();
List<Integer> list=new ArrayList<>();
list.add(1);
list.add(2);
map.put(1,list);// key is 1, values 1 and 2
you can retrieve values as follows
map.get(1) // will return list which contains values 1 and 2
Edit:
HashMap<Integer, User> nodes = new HashMap<Integer, User>();
User user=new User(1,2);// creating a user
nodes.put(1,user);
Now you can get values
nodes.get(1)// will return user
2
solved I want to store two integer value with an integer key value [closed]