Hi Anamika i am trying to explain the following program.....
as below:
In the main method you can see constructor is being called
FindAt();
but just before that two static variables have been declared
of type Pattern and Matcher(just as we declare variables of type
Integer etc..)
private static Pattern pattern;
private static Matcher matcher;
...Than as the contructor gets called
pattern = Pattern.compile("@");
matcher = pattern.matcher("@someisp.com");
the variable pattern can hold a pattern type variable
so using the
class Pattern we call compile method on it.........
Pattern.compile("@")
now since pattern has a pattern in it now we
so now we are calling pattern.matcher () method
which will return a matcher,so we can assign it to
a matcher
matcher=pattern.matcher("");
Later an if condition is being used if it returns true
than System.out.println("")gets executed
If you want to know about Pattern and Matcher types
than please refer to java API
and specifically below shown package
import java.util.regex.*; I hope this helps...................
Preparing
SCJP 1.5