Java - retrieve object of certain class
<p>For some time I'm programming in J2ME. I wanna create "super" game 2D now. At first take most important data:</p>

<ul>
<li>game is shooting where you go with soldier and fire to enemies</li>
<li>each soldier is once object of <code>Soldier</code> class (inherits after <code>Sprite</code>)</li>
<li>each soldier is able to generate bullet - objects of <code>Bullet</code> class (inherits after <code>Sprite</code>, too)</li>
</ul>

<p>And I got problem here. It's so: bullet hits in soldier. How I can transfer soldier's object to bullet's object (or vice versa) to decrease HP of soldier.</p>

<p>Next data at glance:</p>

<ul>
<li><code>Soldier</code> class have got static field <code>HP</code></li>
<li><code>Bullet</code> class have got static field <code>hit</code> contains data about bullet's force</li>
</ul>

<p>I've conditional statement that check whether player collides with trpas - TiledLayer. It is not no problem. Problem is checking collison with bullets.  <code>collidesWith()</code> method checks collides with once object of <code>Sprite</code>, <code>TiledLayer</code>, <code>Layer</code>. And bullet's objects will be a lot. Is here such option to check collision with certain type and not with certain object of certain type (not check collision with bullet1, bullet2, bullet3 as queue, and with all what is type of <code>Bullet</code>)?</p>

<p>My questions.</p>

<p>1.How I can transfer Bullet's data to Soldier if collision occured?
 2. How I can detect collision with <code>Bullet</code> type, not with object this type x bullet number?</p>
