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 ??

Edited 6 Years Ago by doha786: n/a

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.