title: Java Cannot infer type arguments for "Class"<>
body: <p>Hello so I have been trying to figure this problem out for a bit now and I googled. I have found posts on here with the same problem, but they didn't really help me. </p>
  
  <p>In my JUnit test the call for 
  PaymentBatchProcessor checkProcessor = new PaymentBatchProcessor&lt;>();</p>
  
  <p>causes "Cannot infer type arguments for PaymentBatchProcessor&lt;>"</p>
  
  <p>I just learned about Generics and that's why I'm having such a hard time implementig it. I understand the general concept of Generics.</p>
  
  <pre><code>    public class PaymentBatchProcessor &lt;T extends Payment&gt; {
  
          // Variables
          private T payment;
  
          List &lt;T&gt; listOfPayments;
  
          // Constructor
          public PaymentBatchProcessor(T payment) {
              this.payment = payment;
              this.listOfPayments = new ArrayList&lt;&gt;();
          }
  
          // add method
          public void add(T payment) {
  
              this.listOfPayments.add(payment);
          }
  
          // getMax method
          public double getMax () {
              // Placeholder
              double maxAmount = 0.0;
  
              for( T payment : listOfPayments) {
                  // displaying each payment to console
                  System.out.println(payment);
  
                  // If current payment is more then current maxAmount
                  //      assign new highest amount
                  if(payment.getAmount() &gt; maxAmount) {
                      maxAmount = payment.getAmount();
                  }
              }
              // Return highest amount
              return maxAmount;   
          }// END OF getMax()
  
  
          // getTotal method
          public double getTotal() {
  
              // Accumulator
              double total = 0.0;
  
              // Add each payment amount to total
              for( T payment : listOfPayments) {
                  total +=  payment.getAmount();
              }
  
              return total;
          }// END OF getTotal()
  
          // getSize method
          public int getSize() {
              // Return size of list
              return listOfPayments.size();
          }
  
  }// END OF PAYMENTBATCHPROCESSOR
  
  
  
  //Interface
  public interface Payment {
  
          public  double getAmount();
          public void setAmount(double amount);
  
  
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  
  
      // Check class
      public class Check implements Payment{
          // Variable
          private double amount;
  
          // Constructor
          public Check (double amount) {
              this.amount = amount;
          }
  
          // Getter and Setter
          public double getAmount() {
              return this.amount;
          }
  
          public void setAmount(double amount) {
              this.amount = amount;
          }
      }// END OF CHECK
  
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  
      public class IOU implements Payment {
          // Variable
          private double amount;
  
          // Constructor
          public IOU (double amount) {
              this.amount = amount;
          }
  
          // Getter and Setter
          public double getAmount() {
              return this.amount;
          }
  
          public void setAmount(double amount) {
              this.amount = amount;
          }
      }// END OF IOU
  }
  // +++++++++++++ PROBLEM AREA +++++++++++++++++++++++++++++++++++++++++++++++++
  
  import static org.junit.Assert.*;
  import java.util.ArrayList;
  import org.junit.Test;
  
  
  
  public class TestGenerics
  {
  
      @Test
      public void testProcessorAsCheck()
      {
          PaymentBatchProcessor&lt;Check&gt; checkProcessor = new PaymentBatchProcessor&lt;&gt;();
  
          checkProcessor.add( new Check(5.00) );
          checkProcessor.add (new Check(10.00) );
  
          assertEquals(15, checkProcessor.getTotal(), 2);
          assertEquals(10, checkProcessor.getMax(), 2);
      }
  
      @Test
      public void testProcessorAsIOU()
      {
          PaymentBatchProcessor&lt;IOU&gt; processor = new PaymentBatchProcessor&lt;&gt;();
  
          processor.add( new IOU(22.54) );
          processor.add( new IOU(22.55) );
  
          assertEquals(45.09, processor.getTotal(), 2);
          assertEquals(22.55, processor.getMax(), 2);
      }
  
      @Test
      public void testProcessorAsPayment()
      {
          Payment iou = new IOU(11.22);
          Payment iou2 = new Check(22.11);
  
          PaymentBatchProcessor&lt;Payment&gt; processor = new PaymentBatchProcessor&lt;&gt;();
  
          processor.add(iou);
          processor.add(iou2);
  
          assertEquals(33.33, processor.getTotal(), 2);
          assertEquals(22.11, processor.getMax(), 2);
      }
  
      @Test
      public void testProcessorAsPaymentWithEmptyList()
      {
          PaymentBatchProcessor&lt;Payment&gt; processor = new PaymentBatchProcessor&lt;&gt;();
  
          assertEquals(0, processor.getTotal(), 2);
          assertNull(null, processor.getMax());
      }
  
      @Test
      public void testProcessorHelperAsPayment()
      {
          ArrayList&lt;Payment&gt; list = new ArrayList&lt;Payment&gt;();
  
          list.add( new Check(10.00) );
          list.add( new Check(5.00) );
          list.add( new IOU(1.00) );
  
          assertEquals(10, PaymentProcessorHelper.&lt;Payment&gt; getMax(list).getAmount(), 2);
          assertEquals(16, PaymentProcessorHelper.&lt;Payment&gt; getSum(list), 2);
      }
  
      @Test
      public void testProcessorHelperAsPaymentEmptyList()
      {
          ArrayList&lt;Payment&gt; list = new ArrayList&lt;Payment&gt;();
  
          assertNull(PaymentProcessorHelper.&lt;Payment&gt; getMax(list));
          assertEquals(0, PaymentProcessorHelper.&lt;Payment&gt; getSum(list), 2);
      }
  
      @Test
      public void testProcessorHelperAsCheck()
      {
          ArrayList&lt;Check&gt; list = new ArrayList&lt;Check&gt;();
  
          list.add( new Check(10.00) );
          list.add( new Check(5.00) );
  
          assertEquals(10, PaymentProcessorHelper.&lt;Check&gt; getMax(list).getAmount(), 2);
          assertEquals(15, PaymentProcessorHelper.&lt;Check&gt; getSum(list), 2);
      }
  
      @Test
      public void testProcessorHelperAsIOU()
      {
          ArrayList&lt;IOU&gt; list = new ArrayList&lt;IOU&gt;();
  
          list.add( new IOU(11.22) );
          list.add( new IOU(22.11) );
  
          assertEquals(22.11, PaymentProcessorHelper.&lt;IOU&gt; getMax(list).getAmount(), 2);
          assertEquals(33.11, PaymentProcessorHelper.&lt;IOU&gt; getSum(list), 2);
      }
  
  }
  </code></pre>