title: How to call a generic method using super class
body: <p>I have got some methods that are common to two subclasses so i have put them in Abstract superclass but there is one method that uses a variable with two different values so i am confused how to implement that method the code is like:</p>
  
  <p>StandardMember class got this method with its own different value for <strong>remainingCredit=30</strong> at starting</p>
  
  <pre><code>public void borrowHolding(int holdingId)
              throws InsufficientCreditException, MultipleBorrowingException {
          // TODO Auto-generated method stub
  
          System.out.println("Hello");
          Holding tempHolding = Library.libCollection.getHolding(holdingId);
          if (Library.libCollection.getHolding(holdingId) != null) {
              if (tempHolding.isOnLoan()) {
                  System.out.println("Can not be issued Currently on Load");
              } else {
                  System.out.println("Can be issued");
                  remainingCredit-=tempHolding.getDefaultLoanFee();
                  System.out.println(getRemainingCredit());
                  tempHolding.setLoanCheck(true);
                  currentlyBorrowedHolding.put(holdingId, tempHolding);
                  System.out.println(remainingCredit);
                  System.out.println(holdingId);
              }
          }
  </code></pre>
  
  <p>PremiumMember Class got same method but the value of <strong>remainingCredit is 45</strong>, Whereas all the methods common to them are implemented in this AbstractMember class which implements the <strong>Member interface</strong>. but when i try to call these method from other class i have to initialize the object of AbstractMember in Library Class like this </p>
  
  <pre><code>Member member = new StandardMember();
  </code></pre>
  
  <p>which is very bad because I can not use the StandardMember object to run the PremiumMember Object's version of same method. so, either i should create new object of PremiumMember Class or i dont know what to do. but if i create two objects then this member object is being used in borrowHolding method which is basically a cascading method in Library Class which in turn calls the borrowHolding method in Member Interface:</p>
  
  <pre><code>public void borrowHolding(int holdingId) throws InsufficientCreditException, MultipleBorrowingException {
          if(libCollection.holdingMap==null){
              System.out.println("Collection is Empty");
          }
          if(libCollection.holdingMap.containsKey(holdingId))
          member.borrowHolding(holdingId);        
      }
  </code></pre>
  
  <p>the problem is i can not create two objects because at runtime i can only call one method. so help me out how to implement this method in Abstract class so that program will detect the difference that which object it should create.</p>