title: Why interface can be used to get callback on java?
body: <p>Im using this code on this <a href="https://stackoverflow.com/questions/28120029/how-can-i-return-value-from-function-onresponse-of-volley">question</a> :</p>
  
  <pre><code>   public void getString(final VolleyCallback callback) {
      StringRequest strReq = new StringRequest(Request.Method.GET, url, new     Response.Listener&lt;String&gt;() {
          @Override
          public void onResponse(String response) {
              result=response;
              callback.onSuccess(result);
          }
      }...
  }}
  
  public interface VolleyCallback{
      void onSuccess(String result);
  }
  </code></pre>
  
  <p>my question is <strong>why this interface can be use to listening the response</strong>. as i know in java interface is some kind of contract and or some abstract class that has some method. Interface need to be implement before we actually use it but in those code above there are not any implement code....</p>
  
  <p>but the new object based on that interface can be populate as listener. need some concise explanation why this concept happen. </p>
  
  <p>thanks for any explanation. </p>