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

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

Moderator: admin

Post Reply
ETS User

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

Post by ETS User »

Shouldn't it be \\d\\d instead of \d\d in the question?

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

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

Post by admin »

No, \\ is required only when you specify the \d in java code.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Thadir
Posts: 5
Joined: Mon Aug 19, 2013 4:49 am
Contact:

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

Post 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());
	}

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

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

Post by admin »

Yes, it would be better :)
Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 16 guests