1

In Qmetry,Trying to save array of arraylist string and access same in another test case.

Array of array list :

ArrayList<ArrayList<String>> my_list

store(my_list, "array_list_1");

//Accessing saved list

Object list_details = getBundle().getObject(array_list_1);

System.out.println("++++ saved list details++++" + list_details);

I am able to print list_details content. Till this there is no issue. But when I try to get the first index within the arraylist, not able to use .get(0) method. Below is the code.

ArrayList<String> list_details1 = list_details.get(0);

When tried typecasting , got an error 'java.lang.String cannot be cast to java.util.ArrayList'

typecast:

ArrayList<ArrayList<String>>list_details1 =  (ArrayList<ArrayList<String>>)list_details;

Need to know is it the right way to store and access arraylist ? Please suggest.

sanjay pujari
  • 459
  • 2
  • 7
  • 23

1 Answers1

1

if you want store in file, you can use .csv or .xls to save ArrayList<ArrayList> my_list, if ArrayList<ArrayList> my_list you query from database, you can set as static variable, then you can use in different method

Moon
  • 137
  • 1
  • 7