Whats problem in this code

import java.util.*;
public class Main {
public static void main(String args[]) {
Main trie=new Main();
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
sc.nextLine();
for(int i=0;i<n;i++){
trie.addWord(sc.nextLine());
}
int q=sc.nextInt();
sc.nextLine();
for(int i=0;i<q;i++){
trie.dictionarySearch(sc.nextLine());
}
}
private class Node{
char data;
HashMap<Character,Node> children;
boolean isTerminal;
Node(char data,boolean isTerminal){
this.children=new HashMap<>();
this.data=data;
this.isTerminal=isTerminal;
}

}
private int numWord;
private Node root;
Main(){
this.root=new Node(’\0’,false);
this.numWord=0;

}
public int numWord() {
return this.numWord;
}
public void addWord(String word) {
this.addWord(this.root,word);
}
private void addWord(Node parent,String word) {
if(word.length()==0) {
if(parent.isTerminal) {
//word allready exist
}else {
parent.isTerminal=true;
this.numWord++;
}
return;
}
char cc=word.charAt(0);
String ros=word.substring(1);
Node child=parent.children.get(cc);
if(child==null) {
child=new Node(cc,false);
parent.children.put(cc,child);
}
this.addWord(child, ros);
}
public void dictionarySearch(String str) {
this.dictionarySearch(this.root.children.get(str.charAt(0)),str.substring(1),"");
}
private void dictionarySearch(Node node, String str,String ans) {
if(node==null)
return ;

if(str.length()!=0) {
char cc=str.charAt(0);
String ros=str.substring(1);
ans=ans+node.data;
if(node.isTerminal) {
	//ans=ans+node.data;
	//System.out.println(ans);
}
dictionarySearch(node.children.get(str.charAt(0)),ros,ans);
}else {
	ans=ans+node.data;
	if(node.isTerminal) {
		//ans=ans+node.data;
		System.out.println(ans);
	}
	for(char n: node.children.keySet()) {
		dictionarySearch(node.children.get(n),"",ans);
	}
	
}

}
}

@sksumitkumardiwaker,

Test case:
6
app
apple
application
batman
batmobile
cat
7
ap
bat
batcave
bat
cat
appl
appledore

Correct Output:
app
apple
application
batman
batmobile
No suggestions
batcave
batman
batmobile
cat
apple
application
No suggestions

As mentioned in the questions And if no such words are available for a given search word, add this word to your dictionary. you need to add the word which is not in the dictionary to your dictionary.

In the above example that would be ‘batcave’

Also you are not printing “No Suggestions” incase the word is not present in the dictionary

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.