Page 1 of 1

About Question com.enthuware.ets.scjp.v6.2.116 :

Posted: Tue Jan 17, 2012 11:35 am
by ETS User
Shouldn't it be \\d\\d instead of \d\d in the question?

Re: About Question com.enthuware.ets.scjp.v6.2.116 :

Posted: Tue Jan 17, 2012 9:28 pm
by admin
No, \\ is required only when you specify the \d in java code.

HTH,
Paul.

Re: About Question com.enthuware.ets.scjp.v6.2.116 :

Posted: Tue Aug 27, 2013 4:13 am
by Thadir
Just a question in proper code standards.

The code

Code: Select all

Pattern p = Pattern.compile(args[0]);
	Matcher m = p.matcher(args[1]);
	boolean b = false;
	while(b = m.find())
	{
	    System.out.println(m.start()+" "+m.group());
	}
Is actually setting in the while loop constantly the b.

Is it not better code use to do the following?

Code: Select all

Pattern p = Pattern.compile(args[0]);
	Matcher m = p.matcher(args[1]);
	
	while(m.find())
	{
	    System.out.println(m.start()+" "+m.group());
	}

Re: About Question com.enthuware.ets.scjp.v6.2.116 :

Posted: Tue Aug 27, 2013 8:16 am
by admin
Yes, it would be better :)
Paul.