Can a Java class be an object and an object a class?

Could it Classbe Objectin Java?

I believe that it Classis a plan to create a new one Objects, but at the same time, classes can have static variables and static methods that are called without an instance of the class (object).

And vice versa, can it Objectbe Class?

+4
source share
6 answers

I see the class as a plan for creating new objects

Correctly.

but at the same time, classes can have static variables and static methods that are called without an instance of the class (object).

. , , . .

, ?

, - .


/, , , , static.

+4

.

, , , , . . , ?

, , , , Class. , ? Class . (, , , ...) Class. . , . Class!

+3

Java?

. , . , , ?

, ?

. , , , . , .

,

enter image description here : wikipedia

, , .

enter image description here

+3

, . , jvm . , jvm , .

- , , ( ), . ( - ; -))

- , , , , .

:

, "" oop. , .

+1

?

- : , ( , , ).

?

- .

- , , , . - , .

...

Animal?

, , Animal ( : ).

, ? ?

, , . - ( ) : , , .

, , . ( , ).

0

, Class Object , "" "":

" Class Object Java?"

Object o = String.class; // yes

" Object a Class?"

boolean objectIsClass = o instanceof Class; // yes
0

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


All Articles