5

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<?>?

scravy
  • 11,904
  • 14
  • 72
  • 127
  • most definitely, class names are "optional" – bestsss Dec 25 '11 at 13:09
  • 1
    Although this question may be a duplicate, I was able to reach it through Google even though I didn't reach the one this is a duplicate of, so I'm very glad this hasn't been deleted. – Sofia Paixão May 29 '19 at 13:24

1 Answers1

4

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)

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130