Share on Google+Share on Google+

rahul tiwari
hash map
1 Answer(s)      5 years and 6 months ago
Posted in : Java Beginners

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;


View Answers

September 29, 2011 at 12:56 PM

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){
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));

Related Tutorials/Questions & Answers:
Hash Map
Hash Map  how to add the hash map objects in the list and iterate the objects
hash map
hash map  write a program in hash map , that shows the value in asending order. but not key value. ex: key value ==== ===== k5 ashutosh k1 babita k7 debasis k2 vikas plz help me
hash map
hash map  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...=2; HashMap<Integer,Test> map=new HashMap<Integer,Test>
java code to compare two hash map objects
java code to compare two hash map objects  java code to compare two hash map objects
Using Arraylist or Hash Map - Java Interview Questions
Using Arraylist or Hash Map  what could b the pros and cons changing between Hash Map to Array List
read from file and store using hash map
read from file and store using hash map  I was stuck with a java project where I have to read a file with two different concepts and store them differently in hashmap. My data file would be something like Adults: Name, xyz
map  using map, i want display message based on id selected [both are strings]   i do no   Hi Friend, Try the following code...) { Map map=new HashMap(); map.put("Message1","Hello
Map  If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map either iterator or for each loop or for loop
hash value
hash value   what is the meaning of this line private int hashValue = 0
Hash table
Hash table  Hi guys.. I have question about hash table How to implement a hash table of English words? with these methods ï??· A method put(s...() which returns the number of strings in the table. ï??· A hash method
hash function for java strings
hash function for java strings  hash function for java strings   int hash=7; for (int i=0; i < strlen; i++) { hash = hash*31+charAt(i
Creating a Hash Table
Creating a Hash Table : Java Util       This section explains the implementation of the hash table. What is the hash table and how to create that? Hash Table holds
Store ResultSt Data in a Map
Store ResultSt Data in a Map  i want to store data in a hash Map .Please solve my problem as soon as possible
Java Hash table
Java Hash table   Hi I have to create code to allow the insertion of a sequence of numbers into a hash table,using a fixed size hash table. Then i... of numbers; insert these into the hash table. Can anyone give me any help
Example to show Hash map exception in java
Example to show Hash map exception in java  ... on Hash table. Interface in Mapping -  1)The Hash Map implements map. 2...-value pairs Understand with Example Hash map in java is same as the Hash table
Map interface
Map interface  What is the Map interface
Hash value is not same - Java Beginners
Hash value is not same  Hi, I've two Excel files with same data.... I've generated one way hash using SHA-1 algorithm. But the hash value of Excel 2003 files is not same as the hash value of Excel 2007 file. What might
Interactive map
Interactive map  hi........ i require map to be zoom in and enlarge the area and show its detail. Can anyone tel me how can this be done using java swings .... plz help
Map code
Map code  hi................ I have map of navi mumbai, where i want to see the location vashi, nerul, turbhe.... means want to zoom into this area and then again zoom in and see nerul location more properly or other location
parse map in java
parse map in java  What is a Parser? Can you give the source code to parse map in Java
solution of k map in c
solution of k map in c  write a program in c to solve k-map with digital circuit
Map java Object to database.
Map java Object to database.  How do you map Java Objects with Database tables
Iterate Tag used with a Map.
Iterate Tag used with a Map.  How Iterate Tag used with a Map
about google map
about google map  how to add google map in website
about google map
about google map  how to add google map in website
java program(Hash Table) - Java Beginners
java program(Hash Table)  Store the names of 10 major cities and the names of corresponding countries in a hash table. Accept the name of a city... argument or specifies a city that is not in the hash table.  Hi friend
Usage of Hash Code - Java Interview Questions
Usage of Hash Code  Dear sir, What is Hashcode in Java and What is its usage? Thanks and Regards M.KehtraBalan  Hi Friend, A hashCode is a way of computing a small (32-bit) numeric key from a long
add google map javascript
add google map javascript  How can i add google map using javascript in my web page?   Search for the " Google Maps Javascript API" it will allow you to embed the Google Map into your web Page
map on web page
map on web page   i want to insert an area map in my web page how can i do it ? please answer me soon. Its urgent
One way hash in Java - Java Beginners
One way hash in Java  Hi, What is one way hashing. How... their hash value in Java. Please give some examples. Thank You,  Hi Friend, A one-way hash function is used to create digital signatures, which in turn
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null