You're trying to "free up memory" of an object, and unfortunately there is no one-size-fits-all solution. You must null all active references to the object. Again this all depends on context, on what variables refer to your object of interest. Do this and the GC will free the reference, when it decides that GC'ing needs to be done, something we don't have control over, but only can make suggestions to the GC.
you state in comment:
lets say A is a sodier and if it gets killed I wand to delete him
Then remove him from the soldier duty list, possibly a database or ArrayList.
Best to declare variables in as limited a scope as possible, to have them naturally be freed from all references when no longer needed, and to profile your code so that you can see when it is running into trouble.
You state in comment:
yes the object is in an ArrayList which luckily is public and static so the problem is solved. thans for your broad explanation
No, this is not correct. The ArrayList should not be static nor public but rather should be a private instance field. Making the field static means that it can not be used in an object-oriented way. Making it public means that any object can mutate it at any time, and in complex programs this can lead to difficult to trace problems and increased cyclomatic complexity. It should be mutable only in a controlled way via public methods of the class that holds it. I'm sorry, but your program design sounds flawed suggesting that you will want to review, refactor, improve it. How, it's hard to say based on snippets of information.
hpstands for hitpoints, it appears he is trying to manage aCollectionofEntitys, perhaps he wants to remove it from hisCollection... I don't know.