0

Im trying to write a method that return an array of different objects. i keep gertting different error for no apparent reason. please help me figure out whats wrong.

public static Object[] createArray( )  {//addReturnType createArray() {
  Computer c1 = new Computer("ASUS", "Intel", 8, 50, 2.4);
  Notebook n1 = new Notebook("Google", "Xeon", 20, 4, 4.5);
  Tablet t1 = new Tablet("APPLE", "AMD", 4, 25, 2.0, 11, 8, "IOS10");
  Computer c2 = new Computer("Dell", "Intel", 8, 23, 2.4);

  // define array

    Object[] arr = new Object[4];
    arr[1]=c1;
    arr[2]=n1;
    arr[3]=t1;
    arr[4]=c2;
     

      // return array
    return arr;
}
Mv2156
  • 27
  • 5

0 Answers0