title: how to convert object of one type(Interface) to another(Interface)?
body: <p>I have an an interface Interface1 which has been implemented by class A and has some private variables value set and m sending the object of class A to next class which accepts input as Interface2. so how can i covert this object refering to Interface1 to Interface2?</p>
  
  <pre><code>interface Interface1{}
  interface Interface2{}
  
  class A implements Interface1 {
      private int id;
  
      public void setId(int id)
      {
          this.id = id;
      }
  }
  
  class B {
      Interface1 call(Interface1 i)
      {
          C c = new C();
          c.call2(i); //this should be of type Interface2 so how to do this
          return i;
      }
  
      public static void main(String arg[])
      {
          Interface1 i = new A();
          i.setId(5);
          B b = new B();
          b.call(i);
      }
  }
  
  class c {
      Interface2 call2(Interface2 i)
      {
          return i;
      }
  }
  </code></pre>