This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
What is the result? A. 234 B. 334 C. 2334 D. 0123456 E. 01234456 F. 12334567 G. Compilation fails.
E is correct. The \d is looking for digits. The * is a quantifier that looks for 0 to many occurrences of the pattern that precedes it. Because we specified *, the group() method returns empty Strings until consecutive digits are found, so the only time group() returns a value is when it returns 34 when the matcher finds digits starting in position 2. The start() method returns the starting position of the previous match because, again, we said find 0 to many occurrences.
A, B, C, D, E, F, and G are incorrect based on the above.
My question is...I am not getting how the last digit(6) is getting printed in E??
index position.......012345 Actual String........ab34ef
and what I fell the output should be is 0123445??
Can anyone please give their suggestions on the above problem.Thank you in advance.