My question: Why is linkedhashmap returning an object when I am expecting a string (perhaps my expectations are incorrect?), and how can I compare if a string value "line" contains the value of the linkedHashMap "sections"? I am defining the linked hash map as follows...
 LinkedHashMap<String, String> sections;
 sections = new LinkedHashMap();
Then, I have collected lines of text from a pdf. If certain conditions are met, II split the text on a white space putting the numerical value "#######" as the key and the rest of the line as the value...
 if (tocStartFound == true && tocEndFound == false) {
     if (line.matches("\\d{6}.+")){
     String lineSplit[] = line.split("\\s",2);
     sections.put(lineSplit[0], lineSplit[1]);
 }
Now, when i ask if line.contains(nextSection) I am told an "object cannot be converted to a charSequence."
if (sectionStarted == true){
    Set set = sections.entrySet();
    Iterator iter = set.iterator();
    boolean foundName = false;
    Object nextSection;
    while(iter.hasNext()){
        Map.Entry me = (Map.Entry)iter.next();
        if (foundName == true){
            nextSection = me.getValue();
            nextSection = nextSection.toString();
            break;
        }
        if (sectionName == me.getValue()) {
            foundName = true;
        }
}
Pattern pa = Pattern.compile(".+((?i)end of section).+");
Matcher ma = pa.matcher(line);
if (ma.find() || line.contains(nextSection)){
    System.out.println("End of Section");
    sectionStarted = false;
}
I guess I thought by defining the map with <string,string>, i was enduring that the data would be typed as strings.  Best regards and thanks for the help...
 
     
     
    