Hello everyone,

I am trying to implement an arraylist within a program, which I will explain, and can't put my head around the arraylist ( I may be overthinking or just don't understand the concept).

My program:
1. I am reading and parsing XML file using SAX Parser, which looks as so:

Code:
<SomeMessage><StatusCode>E</StatusCode>
<ErrorDesc>Error Locating Original Payment Transaction</ErrorDesc>
<ErrorNo>2852</ErrorNo>
<ReasonDesc></ReasonDesc>
<OrderId></OrderId>
</SomeMessage>
2. And I have 3 classes that work as so:

a. Transaction Class is the class that sets and provides all variables:

Code:
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class Transaction
{
    private static String ReasonDesc;
     private static String ErrorDesc;
     private static String ErrorNo;
     private static String FileName;
     private static String Er_FileName;
         
     private  static List<Transaction> transactionList = new ArrayList<Transaction>();
       
     public Transaction()
     {
         ErrorDesc = "";
         ErrorNo = " ";
         Er_FileName = " ";
         FileName = " ";
     }
     
     public void setReasonDesc(String errorDesc)
     {
         Transaction.ErrorDesc = errorDesc;
     }
     
     public String getReasonDesc()
     {
         return Transaction.ReasonDesc;
     }
     
     public void setErrorDesc(String ErrorDesc)
     {
         Transaction.ErrorDesc = ErrorDesc;
     }
     
     public String getErrorDesc()
     {
         return Transaction.ErrorDesc;
     }
     
     public void setErrorNo(String ErrorNum)
     {
         Transaction.ErrorNo = ErrorNum;
     }
     
     public String getErrorNo()
     {
         return Transaction.ErrorNo;
     }
     
          public void setErrorFile(String ErrorFileName)
     {
         Transaction.Er_FileName = ErrorFileName;
     }
     
     public String getErrorFile()
     {
         return Transaction.Er_FileName;
     }
     
     public  void setFileName(String fileName)
     {
         Transaction.FileName = fileName;
     }
     
     public String getFileName()
     {
         return Transaction.FileName;
     }
     
     public void addTransaction(Transaction transaction)
     {
         transactionList.add(transaction);
     }
     
     public void setTransactionType(String TransType)
     {
         Transaction.TransactionType = TransType;
     }
     
     public String getTransactionType()
     {
         return Transaction.TransactionType;
     }
     
     public List<Transaction> getTransaction()
     {
         return transactionList;
     }
     
         public String toString()
         {
               StringBuffer buffer = new StringBuffer();
                
               
        buffer.append(" ReasonDesc: \t \t " + getReasonDesc());
                   
                   buffer.append(" ErrorNo: \t \t " +getErrorNo());
                   buffer.append("\n");
               
                   buffer.append(" Error : \t \t \t \t \t \t \t \t " + getErrorDesc());
		
	return buffer.toString();
             
               }

     }
2b. ReadXML class does all the work, including parsing

Code:
public class ReadXMLFile extends DefaultHandler
{
    private String temp = " ";
    private static int File_Indicator = 0;
    Transaction transaction = new Transaction();
    long lastModified = Long.MIN_VALUE;
    List<Transaction> tempList = new ArrayList<Transaction>();
    private boolean Error = false;
    
    //This function looks for latest modified file in folder
      // and reads this 1st of the 2 xml files.
     public void ReadErrorFile() throws IOException, SAXException, ParserConfigurationException
      {
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm;ss");
             long LastModifiedFile = Long.MIN_VALUE;
      
             String directory = "C:/Documents/Error/";
             File ErrorFile = new File(directory);
            String Er_FileName=" " ;
            File[] files = ErrorFile.listFiles();
            
                  for(File file : files)
                {
                      if(file.lastModified() > LastModifiedFile)
                      {
                            LastModifiedFile = file.lastModified();
                            transaction.setErrorFile(directory+file.getName());
                             Er_FileName = transaction.getErrorFile();
                             
                      }
                  }
                   
            
            SAXParserFactory parser = SAXParserFactory.newInstance();
            SAXParser Sparser = parser.newSAXParser();
            
            ReadXMLFile handler = new ReadXMLFile();
            
            Sparser.parse(Er_FileName, handler);
            
            
      }
      //This function reads and parses the 2nd xml file
      public void ReadLogFile(String FileName) throws IOException, SAXException, ParserConfigurationException
      {
          SAXParserFactory parserLog = SAXParserFactory.newInstance();
          SAXParser SparserLog = parserLog.newSAXParser();
          
          ReadXMLFile handler = new ReadXMLFile();
          
          SparserLog.parse("C:/Documents/Archive/"+FileName, handler);
          
          
      }
  
    @Override
    public void characters(char [] buffer, int start, int length)
    {
        temp = new String(buffer, start , length);
     }
    
    @Override
          public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
         {
             
             if(qName.equalsIgnoreCase("SomeMessage"))
             {
                    File_Indicator++;
                    
                    if(File_Indicator == 1)
                    {
                      // tempList = new ArrayList<>(); 
                    }
                    else
                    {
                        File_Indicator = 0;
                    }
             }
             
             
         }

    @Override
        public void endElement(String uri, String localName, String qName) throws SAXException
        {
            
             if(qName.equalsIgnoreCase("StatusCode"))
             {
                    if(temp.equals("E"))
                    {
                        Error = true;
                    }
              }
             
             if(Error==true)
             {
                   if(qName.equalsIgnoreCase("ErrorDesc"))
                  {
                        transaction.setErrorDesc(temp);
                       transaction.addTransaction(transaction);
                   }
                   
                   if(qName.equalsIgnoreCase("ErrorNo"))
                   {
                       transaction.setErrorNo(temp);
                     //  System.out.println(transaction.getErrorNo());
                       transaction.addTransaction(transaction);
                   }
                   
                   if(qName.equalsIgnoreCase("ReasonDesc"))
                   {
                       transaction.setReasonDesc(temp);
                       transaction.addTransaction(transaction);
                    }
                   
                 
             }

    }

2c. And finally I have the main class:

Code:
public class Execute 
{
    public static  void main(String [] args)
    {
         ReadXMLFile readErrorFile = new ReadXMLFile();
         Transaction transaction = new Transaction();
       
         try {
                  readErrorFile.ReadErrorFile();
                  readErrorFile.ReadLogFile(transaction.getFileName());
                 // readErrorFile.ReadList();
                 
                }
                    catch (IOException ex) 
                    {
                         Logger.getLogger(Execute.class.getName()).log(Level.SEVERE, null, ex);
                     } 
                        catch (SAXException ex)
                        {
                             Logger.getLogger(Execute.class.getName()).log(Level.SEVERE, null, ex);
                         } 
                            catch (ParserConfigurationException ex) 
                            {
                                Logger.getLogger(Execute.class.getName()).log(Level.SEVERE, null, ex);
                              }
                  
    }
My question is: If I declare an ArrayList of type class Transaction (class 2a) in the Transaction class,
1. How do I access the ArrayList to add values to it after I
read and parse in class 2b.
2. How can I access that same class in my main class (class 2c).

Currently in my class 2b I am trying to add the elements to arraylist after I read the xml file and set the corresponding value (i.e. after I parse <ErrorDesc> in my xml file, I call setErrorDesc and then add that to ArrayList<Transaction> but that seems to give me stackoverflow exception).

I understand this may be a lot of text and code to read, I have tried my best to narrow it down as much as I can but if you have any questions, please do ask.

I appreciate any input.