Step 3: Edit MultiSplit.java Download the MultiSplit.java file, and open it in jGrasp (or a text editor...

50.1K

Verified Solution

Question

Programming

Step 3: Edit MultiSplit.java

Download the MultiSplit.java file, and open it in jGrasp (or atext editor of your choice). You will need to write a method thatwill take an array of Strings (String[]) along with a regularexpression, and will call split() on each one of those Strings withthe given regular expression. The result of this method should be atwo-dimensional array of String (String[][]).

You will also need to write a method to print out thistwo-dimensional array of Strings.

The main method will call both methods, using “,” as the regularexpression. Example output is shown below, which corresponds to thecommand-line arguments \"one,two,three\" \" alpha,beta,gamma\" \"delta\"\"first,second\":

0: one two three1: alpha beta gamma2: delta3: first second

The output above shows that the 0th element(\"one,two,three\") produced the values one, two, and three when asplit with “,” was performed. Each subsequent line follows the samegeneral pattern for all the subsequent indices in the command-lineargument array

-------------------------------------------------------------------------------------------------------------------------

public class MultiSplit {  // TODO - write your code below this comment.  // You will need to write two methods:  //  // 1.) A method named multiSplit which will take an  //   array of strings, as well as a String specifying  //   the regular expression to split on.  //   The method returns a two-dimensional array, where each  //   element in the outer dimension corresponds to one  //   of the input Strings. For example:  //  //   multiSplit(new String[]{\"one,two\", \"three,four,five\"}, \",\")  //  //   ....returns...  //  //   { { \"one\", \"two\" }, { \"three\", \"four\", \"five\" } }  //  // 2.) A method named printSplits which will take the sort  //   of splits produced by multiSplit, and print them out.  //   Given the example above, this should produce the following  //   output:  //  //   0: one two  //   1: three four five  //  //   Each line is permitted (but not required) to have a trailing  //   space (\" \"), which may make your implementation simpler.  //    // DO NOT MODIFY main!  public static void main(String[] args) {    String[][] splits = multiSplit(args, \",\");    printSplits(splits);  }}

Answer & Explanation Solved by verified expert
3.8 Ratings (604 Votes)
import javautil public class    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students