Question: Write the method getDelimitersList in the code below. The main method contains code to test your solution.Save & RunLoad HistoryShow CodeLens import java.util.*; public class

Write the method getDelimitersList in the code below. The main method contains code to test your solution.Save & RunLoad HistoryShow CodeLens

import java.util.*; public class Delimiters {

/** The open and close delimiters **/ private String openDel; private String closeDel;

/** Constructs a Delimiters object were open is the open delimiter and close is the * close delimiter. * Precondition: open and close are non-empty strings */ public Delimiters (String open, String close) { openDel = open; closeDel = close; }

/** Returns an ArrayList of delimiters from the array tokens, as described in part (a). */ public ArrayList getDelimitersList(String[] tokens) { /* to be implemented in part a */ }

public static void main(String[] args) { Delimiters d1 = new Delimiters("(", ")"); String[] tokens = {"(", "x + y", ")", " * 5" }; ArrayList res1 = d1.getDelimitersList(tokens); System.out.println("It should print [(, )] and it prints" + res1);

Delimiters d2 = new Delimiters("", ""); String[] tokens2 = {"", "yy", "", "zz", ""}; ArrayList res2 = d2.getDelimitersList(tokens2); System.out.println("It should print [, , ] and it prints " + res2); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!