opennlp.tools.util

## Class StringList

- java.lang.Object
- - opennlp.tools.util.StringList

- All Implemented Interfaces:
    Iterable<String>

      public class StringList
      extends Object
      implements Iterable<String>

  The `StringList` is an immutable list of `String`s.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringList(String... tokens)` Initializes the current instance.
    `StringList(String singleToken)` Initializes the current instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `compareToIgnoreCase(StringList tokens)` Compares to tokens list and ignores the case of the tokens.
    `boolean` | `equals(Object obj)`
    `String` | `getToken(int index)` Retrieves a token from the given index.
    `int` | `hashCode()`
    `Iterator<String>` | `iterator()` Retrieves an `Iterator` over all tokens.
    `int` | `size()` Retrieves the number of tokens inside this list.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### StringList

          public StringList(String singleToken)

      Initializes the current instance. Note:
      Token String will be replaced by identical internal String object.
      Parameters:
        `singleToken` - one single token

    - #### StringList

          public StringList(String... tokens)

      Initializes the current instance. Note:
      Token Strings will be replaced by identical internal String object.
      Parameters:
        `tokens` - the string parts of the new `StringList`, an empty tokens array or null is not permitted.

  - ### Method Detail

    - #### getToken

          public String getToken(int index)

      Retrieves a token from the given index.
      Parameters:
        `index` -
      Returns:
        token at the given index

    - #### size

          public int size()

      Retrieves the number of tokens inside this list.
      Returns:
        number of tokens

    - #### iterator

          public Iterator<String> iterator()

      Retrieves an `Iterator` over all tokens.
      Specified by:
        `iterator` in interface `Iterable<String>`
      Returns:
        iterator over tokens

    - #### compareToIgnoreCase

          public boolean compareToIgnoreCase(StringList tokens)

      Compares to tokens list and ignores the case of the tokens. Note: This can cause problems with some locals.
      Parameters:
        `tokens` -
      Returns:
        true if identically with ignore the case otherwise false

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2026 The Apache Software Foundation. All rights reserved.