title: (Java) Comparing values of two variables in if-statement but can't use `.equals()`
body: <p>(Heads up, I've never written a proper program before so bear with me)</p>
  
  <p>I'm trying to write an if-statement that compares the VALUES of the <code>position</code> fields of two instances (which literally returns the integer "position"). Problem is, they are private fields in different classes so I cannot access them directly. Instead, I made methods in each class which return the variable.</p>
  
  <p>Now in my if-statement, this is the condition that is to be true/false:</p>
  
  <p><code>if (enemy1.getPosition() = player.getGun1Position())</code></p>
  
  <p>Now the problem is, if I use <code>=</code> the machine assumes I'm trying to assign a value to the position of <code>enemy1</code> and I've been researching to find that <code>==</code> compares the memory location rather than the value of the two fields.</p>
  
  <p>I have also read that</p>
  
  <p><code>.equals()</code></p>
  
  <p>can be used but I'm assuming it can't be used here because</p>
  
  <p><code>enemy1.getPosition().equals(player.getGun1Position())</code></p>
  
  <p>gives an error when I try it.</p>
  
  <p><strong>NOTE:</strong> I cannot change the fields to public because this is for an assignment and the fields need to be private.</p>
  
  <p>Any help would be appreciated :)</p>