Answered You can hire a professional tutor to get the answer.

QUESTION

The Java String class defines the following method to split a Java String object into multiple fragments of substrings and store them in a returned...

The Java String class defines the following method to split a Java String object into multiple fragments of substrings and store them in a returned String array:

String[] split( String regularExpression)

The regularExpression argument specifies a delimiter or separator pattern.  More detailed information can be found in the Java Document API (http://java.sun.com/javase/6/docs/api/). The following example uses "-" as a separator to split a String object:

String initialString = "1:one-2:two-3:three";

String[] fragments = initialString.split("-");

The resulting fragments array contains three Strings of "1:one", "2:two", and "3:three". One can further split these fragments if needed. For example,

String[] pair1 = fragments[0].split(":");

The pair1 array contains two String objects of "1" and "one".

Given the following line in a text file:

A=Excellent B=Good C=Adequate D=Marginal E=Unacceptable

A method that would read this text file and print out the following:

Grade A is Excellent

Grade B is Good

Grade C is Adequate

Grade D is Marginal

Grade E is Unacceptable

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question