Ani_1 0 Newbie Poster

I'm working on an Anagram Finder program. One of the methods I'm writing introduces the concept of recursive backtracking which I'm completely new to. I'm hoping to get some suggestions of how this works/how to make it work.

I'm trying to implement recursive backtracking in order to display a list of words from a dictionary text file to form anagrams for an input phrase. Here's what I have so far:

public void printAnagrams(String phrase, int max, List<List<String>> anagrams) {
    if (anagrams == null) { 
        throw new IllegalArgumentException(); 
    } else if (max != 0) {
        System.out.println("...");
    } else 
        System.out.println("...");
    for (List<String> element : anagrams)
        System.out.println(anagrams);
}// End of printAnagram method 

If max > 0, only combination of max words or less are displayed.
Since the program is pretty long, the background info is listed in the links below.

AnagramFinder class: Click Here

Client class: Click Here

This is the expected results:

File name? dict2.txt

Phrase to Scramble? off course

All words found in "off course":
[core, course, cs, cure, for, force, forces, four, of, off, offer, offers, or, our, ours, re, score, so, source, suffer, sure, us, use, user]

Max words to include (Enter for no max)? 3

[core, off, us]

[core, us, off]

[course, off]

[cure, off, so]

[cure, so, off]

[force, of, us]

[force, us, of]

[of, force, us]

[of, us, force]

[off, core, us]

[off, course]

[off, cure, so]

[off, so, cure]

[off, source]

[off, us, core]

[so, cure, off]

[so, off, cure]

[source, off]

[us, core, off]

[us, force, of]

[us, of, force]

[us, off, core]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.