stop repetition

stop repetition

i want to know use of Hashmap, and its contains key value option. the problem is , i am accessing records through a loop but I want to access only those records that has unique id. I dont want to use sameid record more than one time. so could u please guide me how to handle this problem.

through this id i m creating a shape node so multiple nodes are build even they have same id so i want to stop repetition.

View Answers

October 11, 2011 at 2:11 PM

import java.util.*;

public class HashMapExample{

  public static void main(String[] args) {

    HashMap hm = new HashMap();
    hm.put(1,"A");
    hm.put(2,"B");
    hm.put(1,"C");
    hm.put(3,"D");
    hm.put(4,"E");

    Set set = hm.entrySet();

    Iterator i = set.iterator();

    while(i.hasNext()){
      Map.Entry me = (Map.Entry)i.next();
      System.out.println(me.getKey() + " : " + me.getValue() );
    }


  }
}









Related Tutorials/Questions & Answers:
stop repetition
they have same id so i want to stop repetition...stop repetition  i want to know use of Hashmap, and its contains key value option. the problem is , i am accessing records through a loop but I want
ModuleNotFoundError: No module named 'stop'
ModuleNotFoundError: No module named 'stop'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'stop' How to remove the ModuleNotFoundError: No module named 'stop' error
Advertisements
how to stop audio (mp3)
how to stop audio (mp3)   if(e.getActionCommand(). equals("Stop... have to stop a song. on writing player.close() it pauses the song rather than stopping it. how should i stop the song keeping in mind i have to play another song
stop the running hidden server
stop the running hidden server  Port 8080 required by Tomcat v6.0 Server at localhost is already in use. The server may already be running in another... will need to stop the other process or change the port number(s). how to stop tis
Version of jetty>stop dependency
List of Version of jetty>stop dependency
Generate array of random numbers without repetition
Generate array of random numbers without repetition In the previous section, you have learnt how to generate an array of random numbers from the given array... repetition. Here we have allowed the user to enter the elements of array
Java how to stop audio
Java how to stop audio  hello i have this code in the main: try { AudioInputStream audio = AudioSystem.getAudioInputStream(new File...); } I want that when i press the stop button in the gui, the audio stops
ModuleNotFoundError: No module named 'stop-words'
ModuleNotFoundError: No module named 'stop-words'  Hi, My Python... 'stop-words' How to remove the ModuleNotFoundError: No module named 'stop... have to install padas library. You can install stop-words python
Version of tomcat>stop-tomcat dependency
List of Version of tomcat>stop-tomcat dependency
How to stop the execution of midlet in j2me?
How to stop the execution of midlet in j2me?  Hi, How to stop the execution of midlet of j2me for a specific amount of time? Thanks & Regards, Sivakumar.JADS_TO_REPLACE_1
stop an infinite for loop - Java Beginners
stop an infinite for loop  class InfiniteForLoop{ public static void main(String[] args) { for(;;){ } } } i want this infinite for loop program to be stopped by another program named kill
Maven Dependency stop >> 4.2.27
You should include the dependency code given in this page to add Maven Dependency of jetty >> stop version4.2.27 in your project
Maven Dependency stop >> 5.1.10
You should include the dependency code given in this page to add Maven Dependency of jetty >> stop version5.1.10 in your project
Maven Dependency stop >> 5.0.alpha1
You should include the dependency code given in this page to add Maven Dependency of jetty >> stop version5.0.alpha1 in your project
Java Thread : stop() method
Java Thread : stop() method In this section we are going to describe stop() method with example in java thread. stop() method : Java thread provides method stop to stop any running thread. It is deprecated  as it causes
stop word removal from text file
stop word removal from text file  i need java source code for stop word removal from a text file
ModuleNotFoundError: No module named 'many-stop-words'
ModuleNotFoundError: No module named 'many-stop-words'  Hi, My... named 'many-stop-words' How to remove the ModuleNotFoundError: No module named 'many-stop-words' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'patois-stop-words'
ModuleNotFoundError: No module named 'patois-stop-words'  Hi, My... named 'patois-stop-words' How to remove the ModuleNotFoundError: No module named 'patois-stop-words' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'virsh-start-stop'
ModuleNotFoundError: No module named 'virsh-start-stop'  Hi, My... named 'virsh-start-stop' How to remove the ModuleNotFoundError: No module named 'virsh-start-stop' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'biased-stop-words'
ModuleNotFoundError: No module named 'biased-stop-words'  Hi, My... named 'biased-stop-words' How to remove the ModuleNotFoundError: No module named 'biased-stop-words' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'celery-graceful-stop'
ModuleNotFoundError: No module named 'celery-graceful-stop'  Hi...: No module named 'celery-graceful-stop' How to remove the ModuleNotFoundError: No module named 'celery-graceful-stop' error? Thanks   Hi
Maven Dependency stop-tomcat >> 3.3.2
You should include the dependency code given in this page to add Maven Dependency of tomcat >> stop-tomcat version3.3.2 in your project
Maven Repository/Dependency: jetty | stop
Maven Repository/Dependency of Group ID jetty and Artifact ID stop. Latest version of jetty:stop dependencies. # Version Release Date You can read more at: Maven Tutorials
how to solve 'Stop Running This Script' Error ?
how to solve 'Stop Running This Script' Error ?  Hi.. When opened the page on IE browser(version : 8.0),it gives an java script error (i.e.Stop Running This Script). I have used jsp/servlet for this. Please help to resolved
Maven Repository/Dependency: tomcat | stop-tomcat
Maven Repository/Dependency of Group ID tomcat and Artifact ID stop-tomcat. Latest version of tomcat:stop-tomcat dependencies. # Version Release Date You can read more at: Maven
How to stop window closing in "internalFrameClosing" event.
How to stop window closing in "internalFrameClosing" event.  In an internal frame listener in the internalFrameClosing event I want to ask the user to confirm closure with a JDialog. The default close operation for the Internal
how to allow or stop using internet - Java Server Faces Questions
how to allow or stop using internet  hello this is my first qusetion I am developing a cybercafe management tool in java,the problem is how to allow or stop the users of cafe using internet by the administrator on other
Need simple java code to start and stop the remote windows service.
Need simple java code to start and stop the remote windows service.  Hi, I Need simple java code to start and stop the remote windows service. Example:There are two servers 1) Server A and 2) Server B. If a notepad.exe file
iPhone play, pause and stop playing music
iPhone play, pause and stop playing music This is the small iPhone SDK example that will show you how to play, pause and stop the music on button...) playSound:(id)sender; -(IBAction) stop:(id)sender; -(IBAction
How to stop java scripting engine when the script being run is taking too much time?
How to stop java scripting engine when the script being run is taking too much time?   How to stop java scripting engine when the script being run is taking too much time? for e,g, in case of infinite loop the memory is getting
Code to STOP Students from navigating anywhere else till the Online exam is over
Code to STOP Students from navigating anywhere else till the Online exam is over  hi guys i am a final year student of engineering and i am working on an ONLINE EXAMINATION SYSTEM just like GATE, GRE usually used by prometrics
Repeat word as many times as it has characters
Repeat word as many times as it has characters in Java This section illustrates you the repetition of same word as many times as it has characters in it. To do this, we prompt the user to enter the word using the Scanner class. After
Iteration
Iteration The concept of Iteration has made our life much more easier. Repetition of similar tasks is what Iteration is and that too without making any... repetition. Now lets have a quick look at the iteration statements which have
JavaScript clearTimeOut method
clearTimeOut() method is used to stop or clear the time out variables value...=window.clearTimeout(intValue);">Stop timeout</button> <
J2ME Command Class
commands namely, screen, back, cancel, ok, help, stop, ..., cancel, ok, help, stop, exit, item;  ...;Stop", Command.STOP, 6);   exit = new 
Car Rentals in Delhi
Car/ Coach Rentals in Delhi Want to visit the city of Delhi in a private car so that you can stop and go at your will? You must be looking for a car rental in Delhi. There are a host of car rentals in Delhi that can offer you best
How to Recover from Penguin 2.0 Update Penalty?
this is to stop doing spamming. Here are few things that a SEO needs to work...: At first stop targeting the search engine, instead target the audience... and blogs are being heavily punished. So, mix up your anchor text. Stop paid linking
Delhi to Agra Tour by Car
to stop and drive at will and have a glance over places of tourist interest
How to Recover from Google Penguin Update and Get the Ranking Back
on different article marketing websites. Immediately Stop Paid Links
A Brief Introduction to Travel
destinations with short stop over's on the way to the final destination to be reached
Kerala Travel Guide
Travel Guide is your one-stop information source to know more about this scenic
PHP FORM Part-7
the time anyone tell it to stop. ADS_TO_REPLACE_1 We also need to mention... and if it couldn't update the starting value, it will stop at the starting value. In other
Threads in Java
Threads in Java help in multitasking. They can stop or suspend a specific running process and start or resume the suspended processes. This helps in increasing the speed of the processes. In Java programming, Java Virtual Machine (JVM
java application - Applet
java application  codes in repetition and decision  codes in repition and decision
vasu86 - Java Beginners
vasu86  Hi! Please give me code to generate random numbers without repetition... between 1 to 100... thanks in advance
Loops
instructed for repetition of the code. PHP Loops ADS_TO_REPLACE_1 In PHP, like other..._TO_REPLACE_5 d. stop when $MyNumber reaches 11; The syntax for incrementing
Classroom, Online and Onsite IT Training
J
J  how can stop back after logout
J
J  how can stop back after logout using javascript
ajax synchronisation
ajax synchronisation  how to stop ajax execution for some specific time

Ads