How to find whether a palindrome can be formed from a given string or not?

Use the following method to find whether a palindrome can be formed from a given string or not.

public static void palindromeFormationStatus(String str)
    {
       
        int [] a = new int[129];
        int s = 0;
       
        for(int i=0;i<str.length();i++)
        {
                a[str.charAt(i)]++;
        }

        for(int j=0;j<129;j++)
        {
               
                if(a[j]>0 && a[j]%2!=0)
                        s++;
               
        }

        if(s>1)
                System.out.println("palindrome cannot be formed");
        else
                System.out.println("palindrome can be formed");
    }

Search