'java: no suitable method found for addAll(java.util.List<java.lang.String>)

I want to pass an array list. I think the error is caused by the search list. i know The addAll method works with collections. Thats why its saying my searchlist can’t be converted to a collection, how can i solve thisThis is the error

my seacrh controller

@FXML
private ListView<?> ListView;

@FXML
private TextField searchbar;

@FXML
private Button searchbtn;

HelloController hc = new HelloController();


public  void  initialize(URL url, ResourceBundle resourceBundle){
    ListView.getItems().addAll();
}

public void searchbtn(ActionEvent actionEvent) throws IOException {
    ListView.getItems().clear();
    ListView.getItems().addAll(hc.searchList(searchbar.getText(),blxckie));//error is detected 
    here :java: no suitable method found for addAll(java.util.List<java.lang.String>)

}

}

My Hello controller with searchlist

 @FXML
private Button btnhome;

@FXML
private Button btnsearch;

@FXML
private Button btnview;

@FXML
private ImageView image;

@FXML
private TextField numfeild;


@FXML
public TextField timefeild;

private static String lope;



public static ArrayList<String> blxckie = new ArrayList<String>();



@FXML
public <sel> File singleFileChooser(ActionEvent event) throws IOException {

    FileChooser fc = new FileChooser();
    File selectedFile = fc.showOpenDialog(null);

    if (selectedFile != null) {

        File sel = new File(selectedFile.getAbsolutePath());
        String lope = String.valueOf(sel);

        int countofwords = wordcount(sel);
        System.out.println("words are : " + countofwords);
        //numfeild.setText(Integer.toString(().throwDice()));

        getRandomWord(String.valueOf(sel));

        numfeild.setText(numfeild.getText() + countofwords);

        numfeild.setStyle("-fx-text-inner-color: blue");// to change text-field color


        return sel;

    } else {

        System.out.println("hmmm, atleast it works but still invalid file");

    }

    return null;


}


public int wordcount(File sel) {


    long start = System.currentTimeMillis();

    int countofwords = 0;

    try {


        BufferedReader br = new BufferedReader(new FileReader(sel));

        String lineStr = null;
        String wordsArr[] = null;

        while ((lineStr = br.readLine()) != null) {
            wordsArr = lineStr.split(" ");
            countofwords = countofwords + wordsArr.length;
        }
        br.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
    long end = System.currentTimeMillis();
    long time = end - start;
    System.out.println(time);
    timefeild.setText(timefeild.getText() + time);
    timefeild.setStyle("-fx-text-inner-color: blue");// to change text-field color


    return countofwords;


}

public  String getRandomWord(String sel ) throws IOException {

    try (BufferedReader reader = new BufferedReader(new FileReader(sel))) {
        String line;
        while ((line = reader.readLine()) != null) {
            String[] wordline = line.split("\\s+");

            if (blxckie.size() < 20) {
                for (String word : wordline) {

                    blxckie.add(word);
                    System.out.println(blxckie);
                }

            }






        }
        Random rand = new Random();
        return blxckie.get(rand.nextInt(blxckie.size()));
    }


}



@FXML
void searchpg(ActionEvent event) throws IOException {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("search.fxml"));
    Parent root  = loader.load();

    SearchController searchControllera = loader.getController();
    


    Stage stage = new Stage();
    stage.setScene(new Scene(root));
    stage.show();



}



public List<String> searchList(String searchWords, List<String> listOfStrings)  {//searchlist
    List<String> searchWordsArray = Arrays.asList(searchWords.trim().split(""));

    return listOfStrings.stream().filter(input ->{
        return searchWordsArray.stream().allMatch(word ->
                input.toLowerCase().contains(word.toLowerCase()));
    }).collect(Collectors.toList());




}

Anyform of help will be muchly appriciated



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source