• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SCJP 5.0 objective 3

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can somone explain to me about the regular expressions and how greedy, reluctant, possesive quantifiers work, also the new locale class and the printf() method.
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might read MZ's SCJP Tiger Notes to dig out the answers.

Nick
 
Bartender
Posts: 3904
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nicholas Cheung:
You might read MZ's SCJP Tiger Notes to dig out the answers.

Nick



Thanks, Nick !

The direct link is : http://java.boot.by/scjp-tiger/ch03s05.html

regards,
MZ
 
author
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For regular expressions, check out the API page for java.util.Scanner. Also Chapter 8 of the 5.0 rev of "Complete Java 2 Certification". Here's an example, reprinted with author's permission



The output is:

bcd
fgh
jkl

See how the vowels have been used as delimiters?

For more richly-defined pattern matching, you can use the quantifiers * + and ?. * matches zero or more occurrences of the preceding string. So "(ab)*" matches an empty string, "abab", "abababab", and so on. The + quantifier matches one or more occurrences, and the ? quantifier matches zero or one occurrences.

In certain arcane situations, it's hard to decide when a quantifier should stop matching. Should it match the longest possible string, or should it match something shorter? A greedy quantifier, which is the only kind covered in the exam, is the simplest: it matches the longest possible string. Reluctant and possissive quantifiers stop short of the longest match, using subtle algorithms that fortunately are WAY beyond the scope of the SCJP exam.

The Locale class is used for formatting text whose appearance depends on the part of the world where the text will be read. A simple example involves floating-point numbers. In the US and much of Asia, pi is written as 3.14159. But in many European countries the decimal "point" is actually a "comma", and pi is written as 3,14159. The following code prints pi, using the current machine's default locale:



The first string arg describes the format: a floating-point number occupying 7 characters, with 5 of those characters to the right of the decimal point/comma. I live in the US, so my output is "3.14159".

You can specify a locale like this:



Now the output is "3,14159".

Locales are especially good for formatting numbers, dates, and currency. These are all things that vary a lot from one locale to another. Again, there's more about this in the new "Complete Java 2 Certification".
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic