Java learning and java
0. above
I used to learn C/CPP before. For some reason, I plan to repeat the basics of Java from the beginning to consolidate it. As a result, I started to learn Java from today. I will write some of my experiences during the Java review process to help me sort out my knowledge.
1. synchronized
The synchronized keyword has never been seen before, so I Googled it. It locks objects, methods, and code blocks so that only one thread can be executed and used at the same time. It is equivalent to a mutex.
Ii. transient
After a class implements the Serializable interface, some of the data does not want to be serialized, such as the password, you can use transient for marking. The marked attributes are not written during serialization. Of course, it is null when reading.
Iii. volatile
It is used to identify a variable as a shared variable. When it is marked by volatile, different threads always get the same value when using this variable. However, volatile is not atomic.
Iv. strictfp
Exact floating point. When a method is declared using strictfp, the float and double expressions in this method strictly abide by the restrictions of FP-Strict. It can be used to avoid floating point calculation errors caused by different hardware, or when more precise values are needed.
V. instanceof
Used to determine whether an instance is an instance of a certain class (or its subclass.
========================================================== ==========
I haven't written a blog for a long time, and I feel like I can't write anything. However, it will work harder.