Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- public class StringClass
- {
- public boolean isPalindrom(String input)
- {
- boolean isPalindrom = true;
- for(int i = 0; i < (input.length() / 2); i++)
- {
- if(input.charAt(i) != input.charAt(input.length() - i))
- isPalindrom = false;
- }
- return isPalindrom;
- }
- public char mostCommon(String input)
- {
- char mostCommon = '\0';
- int length = input.length();
- int currentCounter;
- int max = 0;
- for(int i = 0; i < length; i++)
- {
- currentCounter = 0;
- for(int j = 0; j < length; j++)
- {
- if(input.charAt(i) == input.charAt(j))
- currentCounter++;
- }
- if(currentCounter > max)
- {
- mostCommon = input.charAt(i);
- max = currentCounter;
- }
- }
- return mostCommon;
- }
- public String reverted(String input)
- {
- String reverted = "";
- for(int i = input.length() - 1; i >= 0; i++)
- {
- reverted += input.charAt(i);
- }
- return reverted;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement