title: Is there an easy way to write a method which gets which object an attribute is an attribute of?
body: <p>I'm relatively new to Java and I'm writing a class which will have a list of objects as one of its attributes. What I want to know is if these objects will be able to access the public attributes of the object they are an attribute of. Apologies if this is hard to parse, impossible or comprehend...</p>
  
  <p>I've looked this problem up before and not found any solutions, possibly because of how I'm wording it.</p>
  
  <pre><code>public class Enemy{
      Attack[] attacks;
      int[] stats;
  
      public Enemy(int[] stats, Attack[] attacks) {
          this.stats = stats;
          this.attacks = attacks;
      }
  
      public attack(attackNo) {
          this.attacks[attackNo].execute;
      }
  }
  
  public class Attack{
      public execute() {
          /*Is there a way to access the Enemy object's stats attribute from here?
          If not, how should I rewrite this code?*/
      }
  }
  </code></pre>