title: Java: check if a class exists and call a specific method if it exists
body: <p>Is there a way to do the following? Check if a class exists (in the same package) and if it does exist, check if a particular method exists, and if so, calling it?</p>
  
  <p>Say that I have class X. In some method of class X, I want to do the following:</p>
  
  <pre><code>if (class Y exists) { //Maybe use Class.forName("Y")?
    if ( Y has method a(String, String) ) {
      call Y.a("hello", "world");
    }
  }
  </code></pre>
  
  <p>Is such a thing possible? And is doing such a thing reasonable? Thanks.</p>