I am fairly new to Java and am trying to load a LinkedHashMap that contains an ArrayList of values. I am trying to load the values from a query result from an API based query result (Salesforce).
Here is the error: "Cannot refer to a non-final variable breakdown inside an inner class defined in a different method" - the breakdown variable is underlined in red giving this message, Ive noted the line in concern below.
CODE
public LinkedHashMap<String, ArrayList<String>> sfFundIdsByContact; public ArrayList<String> getFundsIDsForContact(Contact aContact) { QueryResult queryResults = null; ArrayList<String> ids = new ArrayList<String>(); int index = 0; Boolean done = false; String contactid = aContact.getId(); String SCCPBId = null; if(sfFundIdsByContact == null || sfFundIdsByContact.size() <= 0){ //Do the Salesforce API CALL and Return the results ... while (! done) { SObject[] records = queryResults.getRecords(); for ( int i = 0; i < records.length; ++i ) { if(sfFundIdsByContact.containsKey(breakdown.getSalesConnect__Contact__c())){ sfFundIdsByContact.get(breakdown.getSalesConnect__Contact__c()).add(breakdown.getId()); } else { //Line below in the add(breakdown.getId() - contains the error sfFundIdsByContact.put(breakdown.getSalesConnect__Contact__c(), new ArrayList<String>() {{ add(breakdown.getId()); }}); } } All suggestions are appreciated.