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();
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 ??

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();