/**
*
* @author javadb.com
*/
public class Main {
/**
* This method counts the number of letters in a String
*/
public void countLetters(String str) {
if (str == null)
return;
int counter = 0;
for (int i = 0; i < str.length(); i++) {
if (Character.isLetter(str.charAt(i)))
counter++;
}
System.out.println("The input parameter contained " + counter + " letters.");
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
new Main().countLetters("abcde123");
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment