static boolean allCharactersSame(String s){
        int n = s.length();
        for (int i = 1; i < n; i++)
          if (s.charAt(i) != s.charAt(0))
            return false;
      
        return true;
      }
      

      Java language logo
      To check if all characters are same

      Java Recipes

      The function allCharactersSame() checks if the strings s and s are the same by comparing their characters.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.