Skip to content

Latest commit

 

History

History
169 lines (78 loc) · 2.27 KB

README-BasicArrayUtils.md

File metadata and controls

169 lines (78 loc) · 2.27 KB

BasicArrayUtils

  • Ensure each of the test cases in the class BasicArrayUtilsTest successfully passes upon completion of each of the method stubs in the class BasicArrayUtils.
    • String getFirstElement(String[])
    • String getSecondElement(String[])
    • String getLastElement(String[])
    • String getSecondToLastElement(String[])





String getFirstElement(String[] stringArray)

  • Description
    • Given a string array, stringArray, return the first element of the array.

Example

  • Sample Script

    // Given
    String[] inputArray = {"The", "quick", "brown"};
    
    // When
    String outcome = BasicArrayUtils.getFirstElement(inputArray); 
    
    // Then
    System.out.println(outcome);
    
  • Sample Output

    The
    





String getSecondElement(String[] stringArray)

  • Description
    • Given a string array, stringArray, return the first element of the array.

Example

  • Sample Script

    // Given
    String[] inputArray = {"The", "quick", "brown"};
    
    // When
    String outcome = BasicArrayUtils.getSecondElement(inputArray);
    
    // Then
    System.out.println(outcome);
    
  • Sample Output

    quick
    





String getLastElementTest(String[] stringArray)

  • Description
    • Given a string array, stringArray, return the second element of the array.

Example

  • Sample Script

    // Given
    String[] inputArray = {"The", "quick", "brown"};
    
    // When
    String outcome = BasicArrayUtils.getLastElement(inputArray);
    
    // Then
    System.out.println(outcome);
    
  • Sample Output

    brown
    





String getSecondToLastElement(String[] stringArray)

  • Description
    • Given a string array, stringArray, return the second to last element of the array.

Example

  • Sample Script

    // Given
    String[] inputArray = {"The", "quick", "brown"};
    
    // When
    String outcome = BasicArrayUtils.getSecondToLastElement(inputArray);
    
    // Then
    System.out.println(outcome);
    
  • Sample Output

    quick