Sobes.tech
Junior — Middle

Is it possible to have two classes with the same full name in JVM at the same time?

sobes.tech AI

Answer from AI

In a standard JVM, a single ClassLoader cannot have two classes with the same fully qualified name (package + class name). If you try to load a second class with the same name, an error will occur.

However, in JVM, it is possible to have multiple ClassLoaders, and each can load its own class with the same fully qualified name. This is often used in application containers or plugin systems for class isolation.

Therefore, in JVM, it is possible for two classes with the same fully qualified name to exist simultaneously if they are loaded by different ClassLoaders.