You have to return an ArrayList back to the main function and save it into a variable in the scope of the main function. Like so:
ArrayList x;
x = fetchTicketkey();
When i did this it said "cannot convert from list to arraylist so i changed your function to return an ArrayList instead of an Array. So the whole thing would look like this:
public ArrayList fetchTicketkey()
{
ArrayList li = new ArrayList();
String str="";
try
{
String query = "select tktkey from tktgame2day1 where start_draw=1";
System.out.println("IN THE METHOD ");
con=databaseConnection.getConnection();
pstmt=con.prepareStatement("query");
rs=pstmt.executeQuery();
while(rs.next())
{
li.add(rs.getString("area_name"));
}
rs.close();
con.close();
}
catch(Exception e)
{
System.out.println(" ERROR in getting the values from tktgame2day1 Table "+e);
}
return li;
}
public static void main(String[] args)
{
ArrayList x;
x = fetchTicketkey();
}