I have a generic class with parameter that extends Paint. I really don't understand why I should cast it manually to T in first constructor. What am i doing wrong? Or this is the case when the compiler can't determine a safe cast itself?
public class XYPlot <T extends Paint> extends AbsPlot implements XYChartElement { public XYPlot(AbsSeries series){ setUp(series, (T) new Paint(DEFAULT_PAINT));//TODO } public XYPlot(AbsSeries series, T paint){ setUp(series, paint); } private void setUp(AbsSeries series, T paint){ if(series == null) throw new NullPointerException("Series is null"); setSeries(series); setPaint(paint); }