3. Many encoded strings contain delimiters. A delimiter is a non-empty string that acts as a boundary between different parts of a larger string. The delimiters involved in this question occur in pairs that must be balanced, with each pair having an open delimiter and a close delimiter. There will be only one type of delimiter for each string. The following are examples of delimiters.
(a) A string containing text and possibly delimiters has been split into tokens and stored in String[] tokens. Each token is either an open delimiter, a close delimiter, or a substring that is not a delimiter. You will write the method getDelimitersList, which returns an ArrayList containing all the open and close delimiters found in tokens in their original order.
The following examples show the contents of an ArrayList returned by getDelimitersList for different open and close delimiters and different tokens arrays.
Subsection4.43.2Check your understanding of the question
There are problems in this section that can help you check your understanding of the question. You can skip these if you think you know what to do already.
Variable declarations start with a type and then a name.
A stringcontaining text and possibly delimiters has been split into *tokens*and stored in Test2String[] tokens.
Each token is either an open delimiter, a close delimiter, or a substring that is not a delimiter.You will write the methodgetDelimitersList,which returns anArrayListcontaining all the open and close delimiters found in tokens in their original order.
A string containing text and possibly delimiters has been split into tokens and stored in String[] tokens. Each token is either an open delimiter, a close delimiter, or a substring that is not a delimiter. You will write the method getDelimitersList, which returns an ArrayList containing all the open and close delimiters found in tokens in their original order.
This section contains a plain English explanation of one way to solve this problem as well as problems that test your understanding of how to write the code to do those things.
The method getDelimtersList needs to return an ArrayList of Strings containing all the open and close delimiters found in the tokens array in their original order.
This implies that the code needs to create an empty ArrayList of type String. Letβs call it delList. The code will loop through the strings in the array tokens from the start to the end and if the current string is equal to either the openDel or closeDel it adds that string to the end of delList. Finally it should return delList.
A string containing text and possibly delimiters has been split into tokens and stored in String[] tokens. Each token is either an open delimiter, a close delimiter, or a substring that is not a delimiter. You will write the method getDelimitersList, which returns an ArrayList containing all the open and close delimiters found in tokens in their original order.