Why String.class == "test" .class

Does anyone know why the sign ==works in comparison .class?

Also, the javadoc method for getClass()how

Returns the execution class of this Object. The return object of the class is an object that is blocked by the static synchronized methods of the class represented.

The actual type of result Class<? extends |X|>, where |X|is the erasure of the static type of the expression that is being called getClass(). For example, a throw is not required in this code fragment:

Number n = 0; 
Class<? extends Number> c = n.getClass();

What does an object locked by static synchronized methods mean?

+3
source share
1 answer

== , () . ", " , ; , .

+7

Source: https://habr.com/ru/post/1779563/


All Articles