LinkedHashMap equivalent for JDK 1.3

Posted on 2004-11-02
Last Modified: 2008-02-01
Im looking for alternative implementation for LinkedHashMap so that my code will work with JDK 1.3. (LinkedHashMap was introduced in 1.4). do u guys know if there are already made code for this (before i try to roll my own). Does the Trove Collection classes have the equivalent? Thanks!
Question by:ibo
    LVL 37

    Expert Comment

    Can't you just copy/paste the code of LinkedHashMap?
    LVL 3

    Author Comment

    ive tried that. but it uses protected classes/attributes of HashMap, so i copy-pasted HashMap, then again HashMap requires another protected code from another class, which means i have to copy another class again. I think that would be my last resort if i didnt find any other alternative solution.
    LVL 13

    Expert Comment

    ok Use Vector, and for your object to be collected into this vector make sure u have implemented:

     public boolan equals(Object obj)

    to be used in:

    LVL 35

    Accepted Solution

    You can download the Jakarta Commons Collections, and they have a similar class "LinkedMap" which will work with 1.3
    LVL 92

    Expert Comment

    Or you could maintain both a list and a map, something like:

    public class ListMap
       List list = new ArrayList();
       Map map =  new HasMap();

       void add(Object key, Object o)
          map.put(key, o);

       Object get(Object key)
          return map.get(key);

       Iterator iterator()
         return list.iterator();


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    If you have upgraded to Java2 update 10 on a Microsoft Windows client, you may have discovered that your Java application does not work as it did before.  For example, the colors of your Java2D graphic may be all wrong for no apparent reason. Aft…
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
    The viewer will learn how to implement Singleton Design Pattern in Java.

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now