Static Control Flow – Part 1

Video Link:

Static Control Flow
1. Identification of Static members from top to bottom
I=0 [RIWO] Read Indirectly Write only state
j=0 [RIWO]
2. Execution of Static variable assignment and static blocks from top to bottom
I=10 [R&W] Read and Write
j=20 [R&W]
3. Execution of main methods

Whenever we are executing a Java class the following sequence of steps will be executed as the part of static control flow
1. Identification of Static members from top to bottom [ 1 to 6]
2. Execution of Static variable assignment and static blocks from top to bottom [ 7 to 12]
3. Execution of main methods [13 to 15]

Read Indirectly Write Only
1. Inside a static block we are trying to read a variable that read operation is called Direct Read.
2. If we are calling a method and with-in that method if we are trying to read a variable that read operation is called In-direct read.
3. If a variable is just identified by JVM and original value not yet assigned then the variable is said to be in RIWO Read Indirect Write only state
4. If a variable is in RIWO state then we can’t perform direct Read but we can perform indirect read. If we are trying to read directly we will get compile Time error illegal forward reference.

Regular Expression – Part 2

Regular Expression

Video:

Character Classes
[abc] – either a , b or c
[^abc] – except a, b, c
[a-z] – any lower case alphabet symbol from a to z
[A-Z] – any lower case alphabet symbol from A to Z
[0-9] – Any digit from 0 to 9
[a-zA-Z] = Any alphabet
[0-9] – Any digit from 0 to 9
[0-9a-zA-Z] = Any alphanumeric symbols
[^0-9a-zA-Z] = Special symbol except alphanumeric symbols

Pre-defined Character Classes
\s – Space character
\S – Expect Space character
\d = Any digit from 0 to 9 [0-9]
\D = Except digit, any character
\w = Any word character [0-9a-zA-Z]
\W = Except word character [special character]
. = Any character

Quantifiers – We can use quantifiers to specify the number of occurrences to match
a = Exactly one ‘a’
a+ = atleast one ‘a’
a* = Any number a’s including zero number
a? = Almost one ‘a’

Java Example –

Java Regular Expression – Part 1

Watch here:



Regular Expression

1. If we want to represent a group of a string according to a particular pattern then we should go for Regular Expression.
e.g. We can write a regular expression to represent all valid mobiles.
e.g. We can write a regular expression to represent all email ids.
2. The main important application areas of regular expressions are a. To develop validation frameworks e.g. email
b. To develop pattern matching applications (control+f in windows, grep in Unix)
c. To develop translators like assemblers, compilers, interpreters etc
Compiler design phases
2.a Lexical Analysis -> Syntax Analysis -> Semantic Analysis -> Intermediate Code Generation (I.C.G) -> Code optimisation (CO) -> Target Code Generation
Lexical Analysis = Tokenization (Scanner). (Implemented based on RE)
Syntax – Parsing
d. To develop digital circuits.
e. To develop communication protocols like TCP/IP, UDP etc

3. A Pattern object is a compiled version of a regular expression, that is, it is a java equivalent object of the pattern. We can create pattern object using compile method of pattern class.
4. We can use Matcher object to check the given pattern in the target string. We can matcher object using matcher method of Pattern class.

Contact us at online.nimit@gmail.com