I am getting error of return statement missing ..Can anyone help ??? It's a code of anagrams | Sololearn: Learn to code for FREE!

+2

I am getting error of return statement missing ..Can anyone help ??? It's a code of anagrams

import java.util.Scanner; public class Solution { static boolean isAnagram(String a, String b) { char []c =a.toCharArray(); char []d =b.toCharArray(); for(int i=0;i<b.length();i++){ for(int j=0;j<a.length();j++){ if(c[i]==d[j]){ d[j]=' '; if(i==a.length()){ return true; } else{ break; } } else if(c[i]!=d[j]&&j==a.length()){ i=b.length(); return false; } } } } public static void main(String[] args) { Scanner scan = new Scanner(System.in); String a = scan.next(); String b = scan.next(); scan.close(); boolean ret = isAnagram(a, b); System.out.println( (ret) ? "Anagrams" : "Not Anagrams" );}}

6/25/2021 3:46:48 PM

Minishreddy Vaidhyula

3 Answers

New Answer

+1

Thanks Martin Taylor