Functions.java 633 B

12345678910111213141516171819202122232425262728
  1. package jsp2.function;
  2. import java.util.*;
  3. public class Functions {
  4. public static String reverse( String text ) {
  5. return new StringBuffer( text ).reverse().toString();
  6. }
  7. public static int countNum( String text ) {
  8. String vowels = "abcde";
  9. int result = 0;
  10. for( int i = 0; i < text.length(); i++ ) {
  11. if( vowels.indexOf( text.charAt( i ) ) != -1 ) {
  12. result++;
  13. }
  14. }
  15. return result;
  16. }
  17. public static String toupper( String text ) {
  18. return text.toUpperCase();
  19. }
  20. public static String tolower( String text ) {
  21. return text.toLowerCase();
  22. }
  23. }