012-002-009
Building a Utility Class with Static Methods
Hard
Problem Description
Building a Utility class with static Methods
In this problem, you will create a program that implements three static methods in a StringUtil class (character counting, string reversal, and palindrome checking), processes a string read from Scanner, and displays the results to standard output.
Learning Objective: Understand designing utility classes with combined static methods
Overview
Define static methods in a StringUtil class to process strings.
Specifications
StringUtil.countChar(String s, char c): Returns the count of character c in string sStringUtil.reverse(String s): Returns the reversed stringStringUtil.isPalindrome(String s): Returns true if string is a palindrome- Read one line from Scanner
- Print count of 'a', reversed string, and palindrome check
Input Example
racecar
Output Format
Count of 'a': 2
Reversed: racecar
Palindrome: true
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up