-1

this is the code from Huffman.java

public static HuffmanCoding encode(String input) {
        char ch;
        Map<Character, List<Boolean>> inputData = buildCode(treeFromFreqTable(freqTable(input)));
        List<Character> mylist = new ArrayList<Character>();

        for (int i = 0; i < input.length(); i++) {
            ch = input.charAt(i);
            mylist.add(ch);
        }
        HuffmanCoding huffman = new HuffmanCoding(inputData, mylist);
        return huffman;
    }

this is the code from HuffmanCoding.java

public class HuffmanCoding implements Serializable {

    private final Map<Character, List<Boolean>> code; // The code.
    private final List<Boolean> data;                 // The data.

    public HuffmanCoding(Map<Character, List<Boolean>> code, List<Boolean> data) {
        this.code = code;
        this.data = data;
    }

it shows this error

java: incompatible types: java.util.List<java.lang.Character> cannot be converted to java.util.List<java.lang.Boolean>

and

The constructor HuffmanCoding(Map<Character,List<Boolean>>, List<Character>) is undefinedJava(134217858)
tkausl
  • 13,686
  • 2
  • 33
  • 50

1 Answers1

0

For this error:

incompatible types: java.util.List<java.lang.Character> cannot be converted to java.util.List<java.lang.Boolean>

You are essentially inserting Characters into a list that accepts ONLY booleans values. Make sure whatever you’re inserting into the list of the correct type. (In this context make sure it’s true/false and no characters like ‘a’, ‘m’, ‘5’ etc).

For this error The constructor HuffmanCoding(Map<Character,List>, List) is undefinedJava(134217858)

It’s telling you that you don’t have a constructor with the parameters you’re passing in. Create the following constructor to get rid of the problem:

Public HuffmanCoding(Map<Character, List> map, List characterList){}

Tloz
  • 307
  • 1
  • 3
  • 12