public static boolean appearsIn(String s, char c)that, given a string s and a character c, verifies whether c appears in s.
appearsIn("pippo", 'i')
should return
true
.
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.
occurrences("pippo",'p')
should return
3
.
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 (
'_'
).underscore("pippo and topolino")
should
return the string "pippo_and_topolino"
.
public static String reverse(String s)that, given a string s, returns the string constituted by the characters of s in inverse order.
reverse("pippo")
should return the
string "oppip"
.
public static String removeVocals(String s)that, given a string s, returns a string obtained from s by removing all vocals.
removeVocals("pippo")
should return the
string "ppp"
.
public static boolean palindrome(String s)that, given a string s, returns the boolean value
true
if the string is a palindrome, false
otherwise."anna"
and "ailatiditalia"
are palidrome
strings).
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.permutations("abc", System.out)
should print the following on standard output:
abc acb bac bca cab cba
Class Main
to test the methods above.