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… | Cheap Nursing Papers

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

"Get 15% discount on your first 3 orders with us"
Use the following coupon
FIRST15

Order Now

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp