MultiKey Example 2 : Collection « Apache Common « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java » Apache Common » CollectionScreenshots 
MultiKey Example 2

import java.util.HashMap;

import org.apache.commons.collections.keyvalue.MultiKey;

public class MultiKeyExampleV2 {

  private static HashMap codeAndLangToText;

  public static void main(String args[]) {

    codeAndLangToText = new HashMap();
    addMultiKeyAndValue("en""GM""Good Morning");
    addMultiKeyAndValue("en""GE""Good Evening");
    addMultiKeyAndValue("en""GN""Good Night");
    addMultiKeyAndValue("de""GM""Guten Morgen");
    addMultiKeyAndValue("de""GE""Guten Abend");
    addMultiKeyAndValue("de""GN""Guten Nacht");

    System.err.println("Good Evening in English: " +
      codeAndLangToText.get(new MultiKey("en""GE")));
    System.err.println("Good Night in German: " +
      codeAndLangToText.get(new MultiKey("de""GN")));
  }

  private static void addMultiKeyAndValue(
    Object key1, Object key2, Object value) {

    MultiKey key = new MultiKey(key1, key2);
    codeAndLangToText.put(key, value);
  }
}
           
       
ApacheCommonMultiKeyExampleV2.zip( 514 k)
Related examples in the same category
1.Collection Bag
2.Transformer Example
3.Collection BidiMap
4.Collection Buffer
5.Collection Closure
6.Comparator Example For BuildIn Data Type
7.Comparator Example For User Defined Class
8.Cookie Bag 2
9.Factory Example 1
10.HashMap Example 1
11.List Example 1
12.MapHeaven 1
13.Multi Key Example 1
14.Set Example 1
15.Set Example 2
16.Bean Comparator ( Sorting based on Properties of class )Bean Comparator ( Sorting based on Properties of class )
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.