Question: Background: Consider these two code fragments: while (sc. hasNext(--*)) ...//1 static final Pattern p = Pattern.compile(--*);//2 while (sc.hasNext(p)) ...//2 What strings does the regular expression

 Background: Consider these two code fragments: while (sc. hasNext("--*")) ...//1 static

Background: Consider these two code fragments: while (sc. hasNext("--*")) ...//1 static final Pattern p = Pattern.compile("--*");//2 while (sc.hasNext(p)) ...//2 What strings does the regular expression --* match? Why is it likely that the second fragment will be faster? Rewrite the following to apply the same optimization as was used to transform fragment 1 above into fragment 2. for (String s: ...) System.out.println(str + " " + s)

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!