In this project, I'm trying to access information from an ArrayList which contains only the dates which are Strings.
Here is part of the class I tried. If not having the whole class makes it hard to understand I can edit...
public ArrayList<String> getTicketDates(){
ArrayList<String> theDateArray= new ArrayList<>();
int i;
for (i=0; i <tickets.size(); i++){
if(tickets .get(i).getPurchased()== false){
theDateArray.add(tickets.get(i).getDate());
}
}
for(int f=0; f<theDateArray.size();f++){
System.out.println(theDateArray.get(f)+ " ");
}
return theDateArray;
}
public int getTickets(String date){
int tix= theDateArray.indexOf(date);
int occurrences= Collections.frequency(theDateArray, tix);
if (tix>=0){
System.out.println(occurrences);
}
return occurrences;
}
The 2nd class, I'm trying to count the amount of times one particular date occurs in the previous ArrayList, but it says that theDateArray cannot be resolved to a variable.
One method I've tried is just calling the entire method getTicketDates(), but what it does is it prints out the ArrayList triple, and the occurrences still don't work.