About Question enthuware.ocpjp.v7.2.1415 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
vddoan
Posts: 2
Joined: Fri Feb 21, 2014 9:42 am
Contact:

About Question enthuware.ocpjp.v7.2.1415 :

Post by vddoan »

Hi,

this should match all propositions

because the . (dot) matches any single character (except the newline character), hence including the white space

I tested with the following code

public static void main(String[] args) {
String str1 = "CooLooLCuuL";
String str2 = "CooLooL and CuuL";
String str3 = "CooL and CuuL";
Pattern pattern = Pattern.compile("C.*L");
Matcher matcher = pattern.matcher(str3);

while (matcher.find()) {
System.out.println(matcher.start() + " " + matcher.group());
}
}

Viet

admin
Site Admin
Posts: 10398
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1415 :

Post by admin »

The question is asking what words will the pattern capture in the given input. It is not asking what words will match the given pattern.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests