java-development-for-beginners-learnit / 06 - Strings in Java /008 Homework review String_en.srt
Tan115's picture
Add files using upload-large-folder tool
33852e5 verified
Raw
History Blame Contribute Delete
2.79 kB
1
00:00:00,000 --> 00:00:01,000
Hello team!
2
00:00:01,000 --> 00:00:04,000
Today we will review solution for coding exercises.
3
00:00:04,000 --> 00:00:07,000
Let's start from the first one pin number formatting.
4
00:00:08,000 --> 00:00:09,000
The solution is pretty simple.
5
00:00:10,000 --> 00:00:15,000
Do you remember that in demo for string formatting, I put examples of precision formatting at the bottom.
6
00:00:17,000 --> 00:00:21,000
Here also was an example about floating point number formatting.
7
00:00:21,000 --> 00:00:25,000
Basically, you can control number of places in your floating point number.
8
00:00:26,000 --> 00:00:27,000
And here is the solution.
9
00:00:27,000 --> 00:00:33,000
You are using specifiers to indicate that you want to format floating point number with scale of one.
10
00:00:34,000 --> 00:00:40,000
After that, you can use newline specifier if you wish, and format pin number again to have floating
11
00:00:40,000 --> 00:00:43,000
point number with scale of two, and so on.
12
00:00:43,000 --> 00:00:46,000
Here you can see results in console output.
13
00:00:47,000 --> 00:00:52,000
The second task ask user to enter text and split words.
14
00:00:52,000 --> 00:00:55,000
Hope you successfully learned regular expressions.
15
00:00:55,000 --> 00:00:59,000
Now you understand that you have different ways to implement this task.
16
00:00:59,000 --> 00:01:03,000
You can list all punctuation marks in regular expression.
17
00:01:03,000 --> 00:01:10,000
And you can use Posix basic regular expression Posix was developed by the Institute of Electrical and
18
00:01:10,000 --> 00:01:15,000
Electronics Engineers, mostly to provide backward compatibility with the traditional simple regular
19
00:01:15,000 --> 00:01:19,000
expressions syntax, providing a common standard.
20
00:01:19,000 --> 00:01:26,000
In Posix, we have different character classes and categories here in comments I listed for you Posix
21
00:01:26,000 --> 00:01:27,000
character classes.
22
00:01:28,000 --> 00:01:34,000
In our regular expression, we can use punctuation class and special character for all white spaces.
23
00:01:34,000 --> 00:01:40,000
Let's split our line in case punctuation marks or spaces will be found in the string one time or more
24
00:01:40,000 --> 00:01:41,000
times in a row.
25
00:01:42,000 --> 00:01:48,000
Let me run this program and I will enter any text here with different amount of spaces and punctuation
26
00:01:48,000 --> 00:01:49,000
marks.
27
00:01:53,000 --> 00:01:56,000
Pressing enter and here all words that I entered.
28
00:01:57,000 --> 00:01:58,000
That's all.
29
00:01:59,000 --> 00:02:02,000
Thank you for your attention and see you in the next lesson.
30
00:02:02,000 --> 00:02:03,000
Aethes.