1 2 Previous Next 15 Replies Latest reply: Apr 16, 2007 7:09 AM by 807606 RSS

    Get null with the HashMap

    807606
      Hi all,

      I need a help with HashMap. I have a set of classes. In one of them I initialized the HashMap to put the key with the object in a method.

      First, the attribute was:

      private HashMap hm ;

      Then, I did like this:

      public void enqueue_Task(Poisson_output e) {
                hm = new HashMap();
                JobSpecifications t = new JobSpecifications();
                t.setPoisson_output(e);
                t.setDSpace();
                t.setCpu();
                t.setMemory();
                hm.put(t.getPoisson_output().getSequence(), t);
                ////hm.putAll(hm);
                q.enqueue(t);
           }

      Then, I wrote this method:

      public HashMap getHash(){
                return hm;
           }

      to call it in the other classes, so I will be able to use the HashMap with its values( keys and objects).

      After that, and in another class, I initialized the HashMap again;

      private HashMap e;

      with this constructor:

      public PoissonSimulation(int time) {
      e = q.getHash();
                }


      And finally, I use this method to get the object with a specific key:

           public JobSpecifications search(double key){
                return (JobSpecifications) e.get(key);
           }

      ============================

      Thats it. But, the problem is that when I ran the last method I get a null value!

      Any help!
        1 2 Previous Next