Class StringSplitter


  • public class StringSplitter
    extends java.lang.Object
    A class that splits a string on character change boundaries.

    The provided code is incomplete. Modify it so that it works properly and passes the tests in StringSplitterTest.java.

    See Also:
    MP2 Documentation
    • Constructor Summary

      Constructors 
      Constructor Description
      StringSplitter()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void main(java.lang.String[] unused)
      Solicit a string and split it whenever the character changes.
      static java.lang.String[] stringSplitter(java.lang.String input)
      Given a string, return a string array that contains the input string split at every change of character.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringSplitter

        public StringSplitter()
    • Method Detail

      • stringSplitter

        public static java.lang.String[] stringSplitter(java.lang.String input)
        Given a string, return a string array that contains the input string split at every change of character.

        For example:

        • "AAbbCC", you should output [ "AA", "bb", "CC" ]
        • "ABC", you should output [ "A", "B", "C" ]
        • "", you should output []

        Your function may be called with an empty or null string. If the string is empty, return an empty array. If the string is null, return null.

        Parameters:
        input - the string to split
        Returns:
        the input split whenever the character changes
      • main

        public static void main(java.lang.String[] unused)
        Solicit a string and split it whenever the character changes.

        You are free to review this function, but should not modify it. Note that this function is not tested by the test suite, as it is purely to aid your own interactive testing.

        Parameters:
        unused - unused input arguments