is it possible to add a object in a HASHMAP

Answer Posted / venkat

yes we can add object in Hashmap

like the example is

ArrayList list=new ArrayList();
list.add(10);

HashMap map=new HashMap();
map.put(list,"13");

here list is object

Is This Answer Correct ?    15 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you use find and replace?

518


Can a static method be final?

560


Is this valid in java ? Can we instantiate interface in java?

550


What is a private class in java?

513


What is arguments in java?

525






public class Test { public static void main(String[] args) { int countA = 0; int countB = 0; int countC = 0; int countD = 0; int countE = 0; int countF = 0; int countG = 0; int countH = 0; int countI = 0; int countJ = 0; int countK = 0; int countL = 0; int countM = 0; int countN = 0; int countO = 0; int countP = 0; int countQ = 0; int countR = 0; int countS = 0; int countT = 0; int countU = 0; int countV = 0; int countW = 0; int countX = 0; int countY = 0; int countZ = 0; } } Can anybody tell me any alternate solution(like loop or something) to automate this initialization process. Ex:- for(char chr='A';chr<='Z'; chr++) { (int) String "count"+chr = 0; }

1854


What is the default size of load factor in hashing based collection?

570


What is methods in java?

518


What is polymorphism and what are the types of it?

513


Can a list be null in java?

547


What are the advantages of user defined functions?

562


What are the differences between string and stringbuffer?

595


What are the advantages of passing this into a method instead of the current class object itself?

1179


can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread

542


What does nextint () do in java?

557