## Exercises on recursion (strings)

1. Write a static method
`public static boolean appearsIn(String s, char c)`
that, given a string s and a character c, verifies whether c appears in s.
For example, the call `appearsIn("pippo", 'i')` should return `true`.

2. Write a static method
`public static int occurrences(String s, char c)`
that, given a string s and a character c, returns the number of occurrences of c in s.
For example, the call `occurrences("pippo",'p')` should return `3`.

3. Write a static method
`public static String underscore(String s)`
that, given a string s, returns a string obtained from s by replacing each blank with the underscore character (`'_'`).
For example the call `underscore("pippo and topolino")` should return the string `"pippo_and_topolino"`.

4. Write a static method
`public static String reverse(String s)`
that, given a string s, returns the string constituted by the characters of s in inverse order.
For example the call `reverse("pippo")` should return the string `"oppip"`.

5. Write a static method
`public static String removeVocals(String s)`
that, given a string s, returns a string obtained from s by removing all vocals.
For example the call `removeVocals("pippo")` should return the string `"ppp"`.

6. Write a static method
`public static boolean palindrome(String s)`
that, given a string s, returns the boolean value `true` if the string is a palindrome, `false` otherwise.
A string is palindrome if, when the string spelled from left to right it is equal to the string spelled from right to left. (e.g., `"anna"` and `"ailatiditalia"` are palidrome strings).

7. Write a static method
`public static void permutations(String s, PrintStream p)`
that, given a string s and a `PrintStrem` p, prints on p all strings obtained by permuting the characters of s.
For example, the call `permutations("abc", System.out)` should print the following on standard output:
```abc
acb
bac
bca
cab
cba
```

Class `Main` to test the methods above.

Sunday, 9-Jan-2005 13:07:52 CET