I'm very new to Java and I'm having an issue with adding a set to a list of sets. The code builds fine but gives me a Null pointer exception whenever I run it, and I have no idea why. Here it is:
public class Jaccard{
List<SentenceUtils> sents;
List<Set> shingleSets;
public Jaccard( List<SentenceUtils> list ){
sents = list;
generateShingleSets();
}
private void generateShingleSets(){
for(int i = 0; i < sents.size(); i++){
String[] shingle = sents.get(i).getShingles();
Set<String> setShingles = new HashSet<>(Arrays.asList(shingle));
}
shingleSets.add(setShingles);
}
Please help if you can.