
how to add object of test class in a hashmap test class is as follows class test{ String str1; String str2; String str3; int i1; int i2; }
values of instance variable is coming from different database tables;

import java.util.*;
class Test{
String str1;
String str2;
String str3;
int i1;
int i2;
Test(String str1,String str2,String str3,int i1,int i2){
this.str1=str1;
this.str2=str2;
this.str3=str3;
this.i1=i1;
this.i2=i2;
}
public String getStr1(){
return str1;
}
public String getStr2(){
return str2;
}
public String getStr3(){
return str3;
}
public int getI1(){
return i1;
}
public int getI2(){
return i2;
}
}
class Example{
public static void main(String[] args)
{
String str1="A",str2="B",str3="C";
int i1=1,i2=2;
HashMap<Integer,Test> map=new HashMap<Integer,Test>();
map.put(new Integer(1),new Test(str1,str2,str3,i1,i2));
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.