I am trying to concatenate two arrays to add labels to the columns of a numeric array and also to add a total after the last row of the array. I have found some code on another Stack Overflow thread How can I concatenate two arrays in Java?. But I get an error
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [[Ljava.lang.Object;
Here is my code
public void getpdf(double[][] pricelist, ArrayList<Piece> in) {
PDDocument doc = new PDDocument();
PDPage page = new PDPage();
doc.addPage( page );
try {
PDPageContentStream contentStream =
new PDPageContentStream(doc, page);
JTable table=gettable(pricelist,in);
Object[] headercol={"Type","Asc","Ref","Commandes","Prix unitaire","Prix total"};
Object[][] content=getTableData(table);
Object[][] global=(Object[][]) concatenate (headercol,content);
//drawTable(page, contentStream, 700, 75, headercol);
drawTable(page, contentStream, 700, 75, content);
contentStream.close();
doc.save("bill.pdf" );
}
catch (IOException ex) {
ex.printStackTrace();
}
}
public <T> T[] concatenate (T[] a, T[][] b) {
int aLen = a.length;
int bLen = b.length;
@SuppressWarnings("unchecked")
T[] c = (T[]) Array.newInstance(a.getClass().getComponentType(), aLen+bLen);
System.arraycopy(a, 0, c, 0, aLen);
System.arraycopy(b, 0, c, aLen, bLen);
return c;
}