Class CharCounter

java.lang.Object
  extended by CharCounter

public class CharCounter
extends java.lang.Object

Provides various counts of the characters in an array.


Constructor Summary
CharCounter(char[] theArray)
          Only constructor associates this CharCounter object with an existing array of characters.
 
Method Summary
 int count()
          Provides the total count of characters (same as the array's length).
 int count(char c)
          Provides the count of a particular character.
 int countDigits()
          Provides the total count of digit characters (0-9).
 int[] countEach(char[] c)
          Provides the counts of each of an array of particular characters.
 int countLetters()
          Provides the total count of letter characters (A-Z, a-z).
 int countOther()
          Provides the total count of other characters (not letters or digits).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharCounter

public CharCounter(char[] theArray)
Only constructor associates this CharCounter object with an existing array of characters. The array is not copied - therefore any changes made to the array elements after a CharCounter object is constructed may affect any or all of the counts provided.

Parameters:
theArray - the array of characters to count.
Method Detail

count

public int count()
Provides the total count of characters (same as the array's length).

Returns:
total number of characters in the array.

count

public int count(char c)
Provides the count of a particular character.

Parameters:
c - the character to count.
Returns:
the number of occurrences of the value of c in the array.

countEach

public int[] countEach(char[] c)
Provides the counts of each of an array of particular characters.

Parameters:
c - the array of characters to count.
Returns:
the number of occurrences (in the array referenced by this CharCounter object) of each value in array c, in the same order as the characters in c.

countLetters

public int countLetters()
Provides the total count of letter characters (A-Z, a-z).

Returns:
the number of occurrences of letter chars in the array.

countDigits

public int countDigits()
Provides the total count of digit characters (0-9).

Returns:
the number of occurrences of digit chars in the array.

countOther

public int countOther()
Provides the total count of other characters (not letters or digits).

Returns:
the number of occurrences of other chars in the array.