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

Recommended Answers

All 2 Replies

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

thanks a lot...

got it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.