I'm programming an rpg where you have many soliders and horses and some soliders can carry things as well as horses.
So wait... the soldiers can carry horses?
(As a side note, you might want to try using proper punctuation. It would make your post much easier to read!)
If I wanted to remove an item would hashmapping each class be better than checking instanceof class with a for loop to find the item?
Better in what sense? Chances are you aren't talking about thousands of items, so you probably won't be able to notice the difference. Does a particular approach make more sense in your own brain? Go with that. Not sure which one makes more sense to you? Try putting together a little example program that tests out each approach. Which one do you like better?
In programming, there is no single correct way to do anything. So you have to figure out what works best for YOU. We can't really help you with that. The only way to figure that stuff out is by trying things out for yourself.
That being said, I'm not sure either one of your approaches makes sense in my brain. Why do you need to do either one? Presumably you have an inventory that a player is choosing from. The player is selecting an instance, or an index, or a key, or something. Why can't you just use that?
For example, if the inventory is just 10 boxes on the screen, then maybe that's an array. If the player clicks on one of the boxes, then you know which index to remove. Or if it's an inventory of named objects, then you could use a Map from names to instances. But I don't think a Map that contains Classes makes a ton of sense. The Map would contain instances.
Honestly it sounds like you might want to try implementing something a little simpler first.