Recorrer un HashMap en Java

La clase HashMap suele ser muy útil para almacenar objetos al estilo clave valor. A continuación verán un código que me parece bastante útil para recorrer este tipo de objetos:

HashMap hm = new HashMap();
hm.put("clave01", "valor01");
hm.put("clave02", "valor02");
hm.put("clave03", "valor03");

Iterator iter = hm.entrySet().iterator();
Map.Entry e;

while (iter.hasNext()) {
e = (Map.Entry);
System.out.println("Clave: " + e.getKey() + " | Valor: " + e.getValue());

Espero les sea útil.


About these ads
    • Erick
    • 4/08/10

    Muchas gracias!!!! realmente bueno porque con eso que el Hashtable ya esta despreciado en NetB 6.9

      • SiaR
      • 4/08/10

      Gracias a ti x tu comentario.


  1. Wow, fantastic weblog format! How lengthy have you ever been blogging for?

    you made blogging look easy. The entire glance of
    your web site is excellent, as neatly as the content!

    • Marcelo
    • 6/11/12

    vale companiero.. me sirvio de mucho

  2. Woah! I’m really enjoying the template/theme of this website. It’s
    simple, yet effective. A lot of times it’s challenging to get that “perfect balance” between usability and visual appeal. I must say that you’ve done a fantastic job with
    this. Also, the blog loads very fast for
    me on Internet explorer. Superb Blog!

  3. There are many different kinds of tools and techniques required to
    deliver an exceptional SEO India results. Spend some
    time to design a good-looking 404 page, site offline page, etc.

    Content, keywords and link building are some of the factors using which Search Engine Optimization services are taken care
    of. Out of those 6 keywords, further reduce the number of keywords.
    Since Google organic rank can bring in thousands of potential customers, search engine position service firms have made a business of promising high positions in search engine results pages.
    If the conversion is higher with a certain keyword or a particular set of keywords, then the SEO vendor can focus
    on the same keyword to get it ranked high in all the search engines.
    Social networking Optimization Websites which
    include Facebook and You – Tube could be the latest examples of how “personal” websites
    can be appropriated for business. There are many
    tools online to help you research relevant keywords, such as the Google Adwords Keyword Tool.
    Moreover, some companies are not able to get the desired results and their
    techniques might even have bad effects on the business’s website. For those of us who are using the internet to make money, we all know that it is absolutely essential to get visitors out to our websites. Search engine optimization is necessary for online businesses because it lets your website get found. Don’t
    Forget to Replace the Default Favicon with Your Logo.

    Basically, if you create links to your website with “ink cartridges” or “printer cartridges” in the anchor text, it will help move your website up on the search results for those key words.

    No – you name some of your images “breast. For this reason, having mentions from these sites have increasingly become a more valuable asset for your internet marketing. Why. In fact, soon, not using RDFa could put a site at a disadvantage. Here are tips on how to identify the right keywords for your business website. And make the work flow smoothly, using good grammar at all times. Never post a half edited article, and never settle for less than your best.

  1. No trackbacks yet.

Deja un comentario

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s


Recibe cada nueva publicación en tu buzón de correo electrónico.

A %d blogueros les gusta esto: