0
int y = 0;

String[] bookHeadings = new String[]{"PRODUCT ID","NAME", "AUTHOR", "ISBN", "PAGES", "YEAR", "HOUSE", "PRICE", "DATE/TIME"};

        while (y < savedOrder.orderBooks.size())
            {      
              finalBooks = new Object [savedOrder.orderBooks.size()][100];           
             Object arr[]  = new Object[]{savedOrder.orderBooks.get(y).getOrder()};
             finalBooks[y] = arr;//savedOrder.orderBooks.get(y).getOrder();
             y++;

        }   
//this is from another class..
Object arr[] = new Object[]
   {
     menu.booksList.get(bookStorageCounter).getProductId(), 
         menu.booksList.get(bookStorageCounter).getProductName(), 
               menu.booksList.get(bookStorageCounter).getAuthor(), 
            menu.booksList.get(bookStorageCounter).getISBN(), 
                  menu.booksList.get(bookStorageCounter).getNumberOfPages(), 
              menu.booksList.get(bookStorageCounter).getYearOfPublication(), 
                    menu.booksList.get(bookStorageCounter).getPublisher(), 
                    menu.booksList.get(bookStorageCounter).getCost(),
                    //menu.dateListOrder.get(orderCounter).getDate(),
                    dateFormat.format(orderDate)
                }; 
          savedOrder.orderBooks.add(new Orders(temporder));

I want to put the result in the table, but i keep getting error, ArrayIndexOutOfBoundsException 1, I get the right result when i try to use this code, yb=0; System.out.println("Book Orders:");

while(yb < savedOrder.orderBooks.size())
    {

        System.out.println(java.util.Arrays.toString(savedOrder.orderBooks.get(yb).getOrder()));
        yb++;
    }
  • What is temporder? It's not assigned anywhere – Roman Pustylnikov Oct 18 '15 at 18:42
  • That part of code works(i deleted it accidently while posting the code).. I just found the answer, because i have the size for bookheadigns 8(product id, name, author..), and for finalBooks only savedOrder.orderBooks.get(y).getOrder()... thats why i get the indexoutofboundsexception 1, but can someone help me to convert this: [1, 1, 1, 1.0, 1, 1, 1, 1.0, 18 October 2015 07:40:57] to some array, for example Object[9], so that after each ',' it goes into Object[0], object[1] etc... –  Oct 18 '15 at 18:46
  • sorry read the answer again after i edited it please,, (i typed that thing wrong first time) –  Oct 18 '15 at 18:49
  • You need to create object of Integer or String respectively and then cast it to Object, for each element. – Roman Pustylnikov Oct 18 '15 at 18:52
  • I tryed to find some easier solution, just dont know how to implement it in the code, String.split(),,, any idea of how to use this one? –  Oct 18 '15 at 18:55
  • http://stackoverflow.com/questions/3481828/how-to-split-a-string-in-java – Roman Pustylnikov Oct 18 '15 at 19:00
  • Thank you for the asnwer :) –  Oct 18 '15 at 19:06

0 Answers0