0

hi,
here is my code having return method that working correctly when i print it from inside of the method, but if i call from main method its shows only one output instead all results..

public class SearchCompare{ 
....
public String process(){
String showResult=null;
...
..

	for (String found: names.keySet()) {
	File file = names.get(found); 
	double compare = SearchCompare.LCS(found, searchName);
showResult="Found Names: "+found+ "Similarity: " +compare+"Path: "+file.getName();
//showResult=found+compare+file.getName();
System.out.println(showResult); //shows all result here...
}

return showResult;
}

public static void main (String[] args){ 
SearchCompare sc=new SearchCompare();
String st= sc.process();
System.out.print(st);//showing only one(the last one) found names
}
}

anybody pls tell me where need to change ??

Edited by doha786: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by doha786
1

If you wanted to show all of the results you'd have to do

showResult= showResult + "Found Names: "+found+ "Similarity: " +compare+"Path: "+file.getName();

or, equivalently,

showResult +="Found Names: "+found+ "Similarity: " +compare+"Path: "+file.getName();
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.