Class StringArray

java.lang.Object
dsa.lab01.solutions.StringArray
All Implemented Interfaces:
StringContainer

public class StringArray extends Object implements StringContainer
An array-based string container.

Contains some number of strings using an array.

  • Constructor Details

    • StringArray

      public StringArray()
      Construct an empty string array.
    • StringArray

      public StringArray(String... strings)
      Construct a string array containing the given strings.
      Parameters:
      strings - the strings
  • Method Details

    • size

      public int size()
      Description copied from interface: StringContainer
      Get the number of contained strings.
      Specified by:
      size in interface StringContainer
      Returns:
      the size
    • contains

      public boolean contains(String string)
      Description copied from interface: StringContainer
      Check if the given string is equal to any of those contained.
      Specified by:
      contains in interface StringContainer
      Parameters:
      string - the string to check for membership
      Returns:
      whether such a string is contained