Cloning an Object

I've been trying to clone one of my custom objects for a few days now and tried all examples i could find. I also added "[RemoteClass]" before every class.
I used a custom (which is probably the same) and the mx.utils.objectutils.copy function:
public static function clone(value:Object):Object
    var buffer:ByteArray = new ByteArray();
    buffer.writeObject(value);
    buffer.position = 0;
    var result:Object = buffer.readObject();
    return result;
Both gave me the same error message:
"ArgumentError: Error #1063: Argument count mismatch on basecreatures.water::Naga(). Expected 1, got 0.
    at flash.utils::ByteArray/readObject() [....]"
The class Naga is being extended by the class Creature, which both require some arguments. I used it like this:
Game.player[ownerid].creaturelist.push(Game.clone(target));
target is an object of the class Naga which is working perfectly. Using some other clone methods, the cloned object didn't get the functions of the Creature class.

I don't believe you can clone objects that lack a zero-argument constructor. Can you make the argument optional?
Maciek Sakrejda
Truviso, Inc.
www.truviso.com
Truviso is hiring: http://www.truviso.com/company-careers.php?i=87

Similar Messages

  • Not able to link the cloned business object in change document

    Hi Experts,
    I cloned standard business object FIPP.  When I give the cloned busniess object in change document linkage, I am getting the error message Business object type ZFI_CREDIT has status modeled. Linkage not possible. Please let me know the proceedue to make the linkage.
    Thanks in advance.
    Regards,
    Viven

    In SWO1 you have a possibility to change the status of your custom business object into implemented.

  • How can we avoid cloning an object?

    how can we avoid cloning an object?

    maddy123 wrote:
    writing a singleton class but i want avoid the client to implement the cloneable for creating objectsHuh? What makes you think that's going to happen? Sounds like you have trust issues amongst developers, which would be better fixed by non-technical means

  • Cloning persistent objects

    Does anyone know if ABAP Persistent Objects support cloning?
    I can clone the object using a SYSTEM-CALL (though I'd rather not), however that would still mean breaking the rules to set the object key to a new value.
    At the moment the only solution appears to be creating a new persistent or transient object via the agent and manually assigning the attributes.

    Thanks Uwe. I knew about the SYSTEM-CALL but in this case it does not help.
    My problem is that the object key of a persistent object does not appear to be easily modified even from within the object. I want to clone the object and then modify the key to avoid insert collisions.
    So far as I can see there is no simple way of modifying the business key of a persistent object.
    For now I've implemented IF_OS_CLONE~CLONE in a public method of my persistent object, created a new persistent object and manually assigned the attributes. Unfortunately the code will have to be modified whenever a new attribute is added.

  • Cloning Display Object in AS3

    Hello all, I am trying to load a SWF in to an Application, then have that application create X amount of that original SWF.  Back in the days of AS2, you call the duplicate function, but no more in AS3.
    So, I have been able to do this by creating a new class then create a new object in a loop (works fine) there are 2 ways i've been able to do this:
    use getDefinition of the linkage Name
    convert DisplayObject to an object then assign the constructor as a class
    Both of these create a unique version of the SWF (GREAT!) however, when i use the second method, the mouse and keyboard events don't work, (even though the added and OEF both work on both) and for the life of me i can't figure out why.
    If i place a breakpoint at the end of the for loop i see that 'b' has 7 listeners.  Anyone have this issue / provide suggestions for solutions?
    Thanks!
    -Andrew
    package
         import flash.display.Loader;
         import flash.display.LoaderInfo;
         import flash.display.MovieClip;
         import flash.display.Sprite;
         import flash.events.Event;
         import flash.events.KeyboardEvent;
         import flash.events.MouseEvent;
         import flash.net.URLRequest;
         import flash.net.getClassByAlias;
         import flash.utils.getDefinitionByName;
         import flash.utils.getQualifiedClassName;
         public class Test3 extends Sprite
              public function Test3(){
                   var loader:Loader = new Loader();
                   loader.contentLoaderInfo.addEventListener( Event.COMPLETE, handleLoadComplete );
                   loader.load( new URLRequest( "some/url/here" ) );
              public function handleLoadComplete( _event:Event ):void{
                   var a:MovieClip = (_event.target as LoaderInfo).content as MovieClip;
                   var c:Class = _event.target.applicationDomain.getDefinition("linkageName");
                   var e:Class = Object( a ).constructor;//Class(a.getDefinitionByName(getQualifiedClassName(a)))
                   for(var i:int = 0; i < 1; i++){
                        var b:MovieClip = new c();
                        b.addEventListener( MouseEvent.CLICK, handleClick );               //if Class == c, fires, else nothing
                        b.addEventListener( MouseEvent.MOUSE_MOVE, handleClick );          //if Class == c, fires, else nothing
                        b.addEventListener( KeyboardEvent.KEY_DOWN, handleClick );          //if Class == c, fires, else nothing
                        b.x = Math.random() * 300;
                        b.y = Math.random() * 300;
                        b.addEventListener( Event.ADDED, handleAdded );                         //fires
                        addChild( b );
                        b.addEventListener( Event.ENTER_FRAME, handleOEF );               //fires
                        b.addEventListener( MouseEvent.CLICK, handleClick );               //if Class == c, fires, else nothing
                        b.addEventListener( MouseEvent.MOUSE_MOVE, handleClick );          //if Class == c, fires, else nothing
              private function handleClick( _event:Event ):void{
                   trace(" in the click" );
                   (_event.currentTarget as MovieClip).x +=20;
              private function handleAdded( _event:Event ):void{
                   trace(" i am added" );
                   (_event.currentTarget as MovieClip).x +=20;
              private function handleOEF( _event:Event ):void{
                   trace(" i've entered a frame" );
                   (_event.currentTarget as MovieClip).x +=20;

    Interesting observation...
    I played with it for awhile and it looks like objects instantiated through constructor and sometimes event classes gotten through applicationDomain.getDefinition loose their InteractiveObject flavor.
    If this is intentional - it may make sense for security reasons (I am not sure about it though). Otherwise, let's what can be found on this topic...

  • Returning cloned objects from EJB Local Interfaces

    We'd like to let our WAS 5/J2EE container manage our transactions/unit of work. However, we don't want to have our objects serialized, so we intend to use LocalInterfaces. Additionally, we want to return value objects that support Toplink indirection such that we are not returning the actual cache object but instead a clone.Our question is, how do we return a cloned object that supports indirection from Toplink that we can later do a deepMergeClone on in an explicit update method?

    Additional Information on the first post:
    The pattern we've been testing is as follows:
    1. We set up LocalInterfaces on our EJB's
    2. The EJB Getters are using acquireNonSynchronizedUnitOfWork() to get a NON-JTS transaction to perform a readQuery. This results in a Cloned Bis object being generated. We then release the UOW and return the object.
    3. The Returned Biz object Getters are using Indirection (probably using the released non-synchronized UOW).
    4. The pattern for UPDATE is that we allow the Web Container code (servlet) to change the Cloned Biz Object, they then submit the CLONED and changed object to an EJB update() method where we use getClientSession().getActiveUnitOfWork() to link to the JTS transaction and perform a uow.deepMergeClone(bizObjectClone);
    We are trying to use the pattern for the following reasons:
    1. Isolation of the Cache to upper layers
    2. Transaction Boundry is the EJB Container
    3. We understand that there is a performance overhead with CLoned Biz Objects but this more mirrors the ValueObject Pattern then anything else we've tried.
    BIG Question:
    1. Is this a supported TopLink Pattern?
    2. If its not supported, can it be?
    3. Do you have any other suggested patterns?

  • Object cloning question

    Hello all,
    I have a question about cloning a class. My class is something like this...
    public class Message implements Cloneable
      int id;
      Fields fromClient;
      Fields fromProcessor;
      Fields toClient;
      Fields toProcessor;
      protected Object clone() throws CloneNotSupportedException
        return (super.clone());
    }FYI, the Fields object is another class that contains a Vector of Field objects... A Field is simple class containing three strings, one string named name, one is named value, the other string is named defaultValue.
    At application startup, I create this class and each of the Fields objects are initialized with various Field object stuff.
    Message baseMessage = new Message();Later in the process, when I need to create a new Message object, instead of doing a 'new' I instead do a
    Message msg1 = baseMessage.clone();The newly cloned msg1 object is then processed and manipulated.
    The problem I am having is that on the next call to
    Message msg2 = baseMessage.clone();the newly cloned msg2 object contains the contents of msg1! This is very strange because I thought that msg2 would be a clone of baseMessage which does not contain any of the information found in msg1...
    Any ideas? I hope I explained it well enough...
    Thanks,
    -Jeff

    Also, did you realy intend your clone() method tobe protected?
    I am not really sure why a make the clone()
    protected. I most likely read somewhere that it
    needed to be protected... Is this a bad thing?Not necessarily. It depends on who you want to be able to clone your object. If you want everbody to be able to, make it public. If you want only classes in that package and subclasses of your class to be able to do it, make it protected. I just wondered because public is probably more common.
    As for your other comment about why you weren't using new: You can still use new to make a deep or shallow copy. It's called a copy constructor.
    public class Message {
      public Message(Message orig) {
        field1 = orig.field1; // shallow copy
        field2 = new Field2(orig.field2); // deep copy, assuming Field2 has such a constructor
        etc.
    }

  • Cloning the class object

    Hi
    I have a class which looks something like this:
    class A
    String name = null ;
    int age = 0 ;
    Object a = null
    Object b = null ;
    The Object classes could be any types including Dates etc but it is not fixed and so I am using object. The problem is that I also want to copy this class. Now I am writing my own constrcutor to make a copy object but there is no clone() method available for object. The api shows one but it doesn't work.
    Any idea what the problem is or how I may copy a raw object?
    Cheers

    go through this example
    Cloning an Object
    class CloneClass implements Cloneable
    public CloneClass()
    public Object clone()
    Cloneable theClone = new CloneClass();
    return theClone;
    public String toString()
    return "Hello";
    public static void main(String[] args)
    CloneClass myObject = new CloneClass();
    System.out.println("MyOjbect: "+myObject);
    CloneClass myObjectClone = (CloneClass)myObject.clone();
    System.out.println("MyObjectCloned: "+myObject);
    //Arrays are automatically cloneable:
    int[] ints = new int[]{123, 234};
    System.out.printf("%s\n","Array Before Clone ...");
    for(int i:ints)
    System.out.printf("%d,\n",i);
    int[] intsClone = (int[])ints.clone();
    System.out.printf("%s\n","Array After Clone ...");
    for(int i:intsClone)
    System.out.printf("%d,\n",i);
    }

  • Some objects can't be selected when cloned (option drag) CS5

    Hi There,
    Several times in CS5, I've noticed that some objects disappear or can't be selected after they've been copied or cloned.
    I can't work out if the issues are related but I did notice that objects which disappear seem to have something to do with reordering automatically in the layers palate. For example, after copying or cloning, an object will move under an object even though it wasn't under it before copying.
    As for not being able to select objects, I currently have a line which I can't select after I optioned dragged it to a new location. At first I thought it had gone under another object as per the issues above but after hitting Command Y, I can see it but can't select it.
    Have triple checked that the line isn't locked - is there another command I might've hit that might lock an object or stop it from being edited?
    Anyway, all suggestions welcome!
    Cheers
    Ben

    Can anyone explain to me what is happening or how I can avoid having these adjacent objects show up on this file? I don't want to open and close each single artboard file because I have hundreds of them.
    Looks like that file got corrupt.
    Copy the one object from the problem file into a new file.
    Then delete the problem file.

  • Is a static var 'copied' when and object is cloned?

    HI,
    If you have an abstract class that has a static object as a property,
    i.e.
    public abstract class xyz implements Cloneable, Runnable {
    static Manager M;
    Thread runner;
    and a concrete class is created by cloning this object, i.e.
    public void run(){
    if(x!=null){ // if we are the server process
    while (runner!=null){
    try{
    Concrete_xyz = (Concrete_xyz) clone(); // (Concrete xyz implements xyz)
    Concrete_xyz.x = null;
    Concrete_xyz.runner = new Thread(Concrete_xyz);
    Concrete_xyz.runner.start();
    }catch(Exception e){}
    }else{
    run(client);
    will all the clones share the static Manager object? ....is this a stupid question?
    any help much appreciated

    Well, not a stupid one, just kinda obvious. There is one and only one copy of each static field for any loaded class. The only time there would be more than one is when more than one class loader loads the class, in which case the classes are truly the same (just happen to have the code).
    Cloning, serialization/deserialization, etc. will never duplicate static fields.
    Chuck

  • Switch between transient and persistent objects?

    Hi Folks,
    I'm Re: transient object to persistent to ask this type of question, but couldn't find an answer.
    Using persistent classes, does anyone know an elegant way to convert a transient object to a persistent one and vice versa? There is no standard functionality provided that I can see, and cloning the object results in clashing keys.
    What am I trying to accomplish?
    I need an object instance which <i>may</i> exist in the DB and if not, it <i>may</i> need to be saved for future use. I'm using a table with key fields K1 and K2 and the app will ask for an object instance using the full key K1+K2.
    If the object doesn't find a DB record for K1K2 then it should instantiate itself with values for K1blank. Here is where I'm considering transient in order to provide the app with default functionality defined in record K1+blank.
    If a write access occurs to a transient object then is should become persistent and the K1+K2 record be created.
    Any ideas appreciated.
    Cheers,
    Mike

    Hi Mike,
    I written something similar working on Persistent Objects.
    The only point of attention is that you cannot create a new persistent while a transient is resident in memory.
    This is checked by the OS system during the creation of a new persistent:
    in method CREATE_PERSISTENT of Basis Class, there is a check on the existing object:
    * Precondition   : No object exists with the given business key, neither
    *                  in memory nor on database.
    So, you can create a new transient, fill it with the values you need and then pass this values to the agent to create a new persistent, but only after releasing the existing transient (because they will have the same key).
    I've solved the problem like this:
    METHOD flush.
    "IMPORTING value(im_transient) TYPE REF TO zcl_liquidate_daily_bo
    "IMPORTING value(im_commit) TYPE xfeld
    "IMPORTING value(im_agent) TYPE REF TO zca_liquidate_daily_bo
    "RETURNING value(re_persistent) TYPE REF TO zcl_liquidate_daily_bo
    "--> raised by event PERNR_PROCESSED
      DATA: s_dip_liq TYPE zhr_tm_dip_liq.
      s_dip_liq-zpernr    = im_transient->get_employee_no( ).
      s_dip_liq-zsocmat   = im_transient->get_matricola_legale( ).
      s_dip_liq-zdataev   = im_transient->get_event_date( ).
      s_dip_liq-zcodev    = im_transient->get_event_type( ).
      s_dip_liq-zdescev   = im_transient->get_event_descr( ).
      s_dip_liq-zmotev    = im_transient->get_event_reasn( ).
      s_dip_liq-zmeseall  = im_transient->get_mese_allineamento( ).
      s_dip_liq-zannoall  = im_transient->get_anno_allineamento( ).
    * // Invalidate the transient before create the persistent!
      im_agent->if_os_factory~release( im_transient ).
      CLEAR im_transient.
      IF im_commit EQ abap_true.
        TRY.
    re_persistent =
    im_agent->create_persistent( EXPORTING i_anno_allineamento = s_dip_liq-zannoall
                                                   i_mese_allineamento = s_dip_liq-zmeseall
                                                   i_employee_no       = s_dip_liq-zpernr
                                                   i_event_date        = s_dip_liq-zdataev
                                                   i_event_type        = s_dip_liq-zcodev
                                                   i_event_descr       = s_dip_liq-zdescev
                                                   i_event_reasn       = s_dip_liq-zmotev
                                                   i_matricola_legale  = s_dip_liq-zsocmat ).
          CATCH cx_os_object_existing.
        ENDTRY.
        COMMIT WORK AND WAIT.
      ENDIF.
    ENDMETHOD.
    This method is called inside a loop on a table that containes references to transient objects.
    For each object I perform some tasks, and if all it's ok I raise the event PERNR_PROCESSED, which automatically calls this method FLUSH, transferring the transient to the persistent.
    Return Object is the new persistent, which will be passed back to the internal table, changing the content from the transient to the new persistent.
    Hope this helps,
    Roby.

  • Problem in cloning a boolean data of an array

    Hi Guyz,
    Just tried my hand in cloning.
    I am trying to clone a class Sam which contains array of Test.
    Test just has a single boolean data type value1.
    In Sample, the object of Sam has the value1 (in Test[0]) as 'false'.
    I have cloned this object. I am changing the value of value1 to 'true' in the original object.
    But its gets reflected in the cloned object too.
    Can anyone please tell me how to retrieve the previous boolean value of the original object.
    class Test
    class Test implements Cloneable
         private boolean value1;     
         public boolean isValue1() {
              return value1;
         public void setValue1(boolean value1) {
              this.value1 = value1;
        public Object clone() throws CloneNotSupportedException {
                      return super.clone();
    class Sam
    class Sam implements Cloneable
         private Test[] testObj;
        public Object clone() throws CloneNotSupportedException {
         Sam sam = (Sam)super.clone();
         sam.setTestObj((Test[])testObj.clone());
         return sam;
        public void setTestObj(Test[] value)
         this.testObj = value;
         public Test[] getTestObj()
              return testObj;
    class Sample
    public class Sample
         public static void main(String[] args)
              try {
              Sam s = new Sam();          
              Test[] t = new Test[1];
              t[0] = new Test();
              t[0].setValue1(false);
              s.setTestObj(t);
              Sam o = (Sam)s.clone();
                                   System.out.println(s.getTestObj()[0].isValue1());
              System.out.println(o.getTestObj()[0].isValue1());
              Test[] rr = s.getTestObj();
              rr[0].setValue1(true);
              System.out.println(s.getTestObj()[0].isValue1());
              System.out.println(o.getTestObj()[0].isValue1());          
         catch(Exception ex)
              ex.printStackTrace();
    }Thanks, Prad.

    Thanks kajbj and Jardium for ur instant reply.
    Jardium, i followed ur suggestion and i got the result !!
    I changed the clone() method of Sam
    public Object clone() throws CloneNotSupportedException {
              Sam sam = (Sam)super.clone();
              if(testObj != null) {
                   Test[] test = new Test[testObj.length];
                   for(int i=0;i<testObj.length;i++)
                        test[i] = (Test)testObj.clone();
                   sam.setTestObj(test);
              return sam;
    }Thanks,
    Prad.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Vector clone references the same objects??

    Hi all
    I'm developing a simple chess program.
    Obviously, each move the user tries must be checked against the following sets of chess rules:
    1.) Whether it is that colour player's turn to move
    2.) Whether this move is valid for this specific piece (eg. 3 forward for a King --> invalid of course)
    3.) Whether this move will jeopardize the player's king (put it in check)
    If from any of the above the move is found to be invalid, the move is not executed.
    My program structure is briefly this:
    A. abstract super class 'ChessPiece' - subclassed by the various specific Chess Piece classes.
    Each of the specific ChessPiece subclasses must implement an abstract method to check if a
    proposed move is valid, and also a method to actually do the move...
    B. 'PieceManager' class - has a Vector of ChessPieces:
    This class checks whether the given move is valid:
    For the piece: by calling the checking method (see A above)
    For the general game: by making sure the given move doesn't put the player's king in check.
    NOTE: In chess (for those who don't know), it is illegal to move any piece if, at the end of
    the move, your king will be in check [possible to be captured by any enemy piece]
    This last check I want to do in the following way:
    1) copy/clone the entire PieceManager object
    2) in this copied object, actually do the move
    3) still in the copied/cloned object, see if the moving player's king is now in check
    4) based on this evaluation, execute the move in the original PieceManger object or don't...
    The Problem:
    When I clone this PieceManager object, its 'pieces' Vector is obviously also cloned.
    BUT it seems that the cloned 'pieces' Vector references the same ChessPiece objects
    as those referenced by the original 'pieces' Vector; ie the 2 Vectors are sharing the same Objects.
    Thus, when I actually execute the move in the test/cloned PieceManager object,
    the original PieceManager's corresponding piece is moved too (well, it seems it is the same piece...).
    I am pretty stuck with this.
    I've tried the Vector clone method; it doesn't seem to copy the objects, but create another reference
    to the same objects, as I've said.
    I've tried cloning the entire object ; also not helping......
    I'd love any comments, helpful pointers, suggestions.
    Also any comments on my program structure... is a Vector the best tool for this job?
    Thanks very much -
    lutha

    Hi all, OP here.
    Ok thanks guys for all your posts...
    two points:
    1) I have tried the "copy constructor", and it seems to be doing the same thing. (ie 'shallow clone')
    What's really frustrating me is that nothing I do seems to actually physically copy the Vector's objects
    to new, separate copies of those objects...
    I had my PieceManager class implement Cloneable (just in case - not too sure on that one; in fact I
    commented that out later), and I overrode the clone method like this:
    public Object clone ()
            PieceManager pm = new PieceManager ();
            Vector pcs = new Vector ();
            // Enumeration e = pieces.elements ();
            //while (e.hasMoreElements ())
            //    ChessPiece p = (ChessPiece) e.nextElement ();
            //pcs.add ();
            //}  // still references the same objects!!
            pieces.trimToSize ();
            int size = pieces.size ();
            Object[] arr = new Object [size];
            Object[] initial = pieces.toArray ();
            System.arraycopy (initial, 0, arr, 0, size);
            for (int i = 0 ; i < size ; i++)
                ChessPiece p = (ChessPiece) arr ;
    pcs.add (p);
    pm.pieces = pcs;
    return pm;
    This all still does the same 'shallow cloning'...
    2) m.winter, my ChessPiece objects are not immutable - they have a co-ordinate field that
    changes as they are moved. This is for getting as called by another object, and for checking in
    the ChessPiece's own internal method for checking whether the passed-in square co-ordinate
    is a valid destination.
    Anyway, I don't think that's the main issue here. How can I properly clone/copy a Vector, resulting
    in :
    a) the original Vector
    b) a new, totally unrelated Vector.
    Thanks again all for your input.
    regards,
    lutha

  • Clone an Object

    Hey everyone,
    I just had a question about cloning an object.
    I have an object and within that object there is a field that holds a "date".
    I want to clone the object x number of times (x is user input) and each clone the "date" is the next day.
    So the second clone's "date" value would be the next day after the first clone's "date" value. I also want each clone stored into an array of that object.
    I have a date class and within that date class is a method called "nextDay" which changes the date to the next day.
    I hope that makes sense.
    Anyways, the way I went about it was this:
    Object original = new Object();
    drawCount = user input;
    Object[] array = new Object[drawCount];
    array[0] = original;
    if(drawCountInt > 1)
         for(int j = 1;j <= drawCountInt;j++)
            Object daClone = (Object) original.clone;
            daClone.date = daClone.date.nextDay();
    }Now that seems like it would work once.
    I am trying to figure out, how would I increment the date in a loop?
    I could not figure out a way to use the counter to maybe make the nextDay happen more often.
    I could not also find a way to make a clone of a clone inside a loop and just use the nextDay on that.
    How would I make a clone off the latest clone inside a for or while loop?
    Sorry if any of this seems a little unclear. Feel free to ask questions of course.

    So something like this then?
    if(drawCountInt > 1)
    {     Array[1] = (Object) original.clone;
             for(int j = 1;j <= drawCount;j++)
                       Array[j] = (Objectt) Array[j].clone;
                       Array[j].date = Array[j].date.nextDay();
    }

  • Java.util.Hashmap doesn't work for a custom object

    Hi,
    i have created a class named ID. I am trying to test it on a Hashmap, but the the "containsKey" and "get" operations do not work. Every operation of the main method returns as if the ID objects have not been inserted. Ideas?
    package swarm.sys.id;
    import java.util.*;
    import java.io.*;
    import swarm.sys.common.*;
    import swarm.sys.interfaces.*;
    public class ID implements IDInterface, Cloneable, Serializable
        String type;
        int body;
        String id;
        private static int idCounter=0;
        public ID(String type, int body)
          this.type=type;
          this.body=body;
          id=type+Ids.padWithZeroes(body);
        public String getType()
          return type;
        }//getType
        public String getBody()
          return Ids.padWithZeroes(body);
        }//getBody
        public int getIntBody()
          return body;
        }//getIntBody
        public boolean equals(Object o)
          if (!(o instanceof ID))
            return false;
          else
              ID id=(ID)o;   
              return (this.getType().equals(id.getType()) && 
                      this.getIntBody()==id.getIntBody());        
        }//equals
        /* factory method, which produces new IDs and afterwards
         * increments the body part
        public static ID newID(String type)
            return new ID(type,idCounter++);
        }//newID
        //implements deep cloning
        public Object clone()
            return new ID(new String(this.type),this.body);
        }//clone
        public String toString()
          return id.trim();
        }//toString
        public static void main(String[] args)
            Hashtable<IDInterface,String> table=new Hashtable<IDInterface,String>();
            table.put(new ID("PEER_",1),"x1");
            table.put(new ID("PEER_",2),"x1");
            table.put(new ID("PEER_",3),"x2");
            table.put(new ID("PEER_",4),"x3");
            table.put(new ID("PEER_",5),"x3");
            ID id1=new ID("PEER_",1);
            ID id14=new ID("PEER_",14);       
            System.out.println("table.containsKey(new ID(PEER_,1)): "+table.containsKey(id1)); //should be true
            System.out.println("table.containsKey(new ID(PEER_,14)): "+table.containsKey(id14)); //should be false
            System.out.println("table.get(new ID(PEER_,1))"+table.get(id1)); //should be x1
    }

    You need to override the hashCode() method.
    http://www.javapractices.com/Topic28.cjp

Maybe you are looking for

  • My macbook pro won't recognize network printer

    Macbook pro is late 2011 running OSX 10.7.5 - Lion, connected wirelessly to home network with airport express. Have an HP deskjet connected with a cable to a MacMini mid 2011 - Yosemite. macbook always has problems printing to this printer on home ne

  • FBL5N Report

    Hi Gurus, When I run the FBL5N report, I was not able to find the Assignment field information for Manual invoices. Normally the Assignment field should be displayed with the same document number of the particular invoice. Can anyone help me where th

  • ITunes getting R6034 runtime error

    Vista x64 / x64 iTunes 9.1.0.79 I tried the fix where you copy the SQLite3.dll and that allows me to at least get started. But every time it starts a backup or applying settings the runtime crashes with R6034. Any suggestions or are we just hoping th

  • All active redo?

    Hi all 11.2.0.1 OEL 6.4 I want to drop a log group which has smaller size so i created a new group. The docs said that at any given point only 2 redo groups are active. But why is that when I select ours, all are active? :( How can I drop the log gro

  • Ipad 2 and sound on a projector

    I connect and mirror powerpoint using HDMI to VGA. I get no sound from the setup. Do I need a cable for sound? It is an older projector and there is no wireless