Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

isanagram java

static boolean isAnagram(String a, String b) {
        
        int lenA = a.length();
        int lenB = b.length();
        
        if (lenA != lenB) {
            return false;
        } 
        
        for (int i = 0 ; i < lenA; i++) {
            String s = "(?i)" + Character.toString(a.charAt(i));
            int c1 = lenA - a.replaceAll(s, "").length();
            int c2 = lenB - b.replaceAll(s, "").length();
            if (c1 != c2) {
                return false;
            } 
        }
        
        return true;
    }
Comment

PREVIOUS NEXT
Code Example
Java :: check how many times a character appears in a string java 
Java :: charat(0).touppercase() java 
Java :: spring boot base url 
Java :: Difference between Public, Private and Protected modifier in Java? 
Java :: guessing game in java 
Java :: List into string java 
Java :: java convert array to list 
Java :: java calendar add minutes 
Java :: public static void main vs static public void main 
Java :: java string array initialization 
Java :: javac clear 
Java :: java gitignore 
Java :: find maximum in array java 
Java :: java clone matrix 
Java :: java read file 
Java :: cmd java compile 
Java :: Concept of Association in java 
Java :: glide dependency 
Java :: java protected private public 
Java :: java 2d array length 
Java :: how to set boolean to false if null java 
Java :: map java 
Java :: java new char array 
Java :: reviews button ade android studio 
Java :: for java 
Java :: multiplication table using while loop in java 
Java :: calculate number of years months and days between two dates in java 
Java :: java delete object 
Java :: what is lambda expression in java 
Java :: difference between class and interface 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =