Can i ask java to do something whenever a method of some class was called
<p>i am new to java and was already surprised some times. so maybe this is possible in java?</p>

<p>I have classes</p>

<pre><code>class X {
      string method_a(int x) {
         String str="abc";
         return str;
      }
}

class Y {
      void before(){};
      void after(){};
}
</code></pre>

<p>Can i tell Java to call methods "before" and "after" of class Y before or after "method_a" of class X is called?</p>

<p>thanks</p>
