Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Java Class objects unique / singletons? [duplicate]

are Class-objects guaranteed to be unique in the JVM, are they Singletons? i.e. will

getClass() == getClass()

always hold true and is

a == b

true if and only if

a.equals(b)

where a and b are of type Class<?>?

like image 970
scravy Avatar asked Oct 09 '22 03:10

scravy


1 Answers

You can have one singleton and/or class per class loader.

a.equals(b) is required to be true if a == b (except if a is null)

like image 193
Peter Lawrey Avatar answered Oct 13 '22 10:10

Peter Lawrey