How much interfaces a class file can implement

sudeep cv picture sudeep cv · Jun 14, 2012 · Viewed 28.2k times · Source

How many interfaces can a class file implement? Is there a limit on the number of interfaces used by a class file? Thanks in advance.

Answer

Hans Z picture Hans Z · Jun 14, 2012

For all practical purposes, there is no limit on the number of interfaces a class can implement, but java does not let you inherit from multiple superclasses.

However, if you really want to nitpick, you can say that the number of interfaces a class can implement is bound by the maximum value the interface id can be in java bytecode, or the amount of code memory you have to implement these interfaces, or the amount of hard drive space to store your bytecode. These are silly arguments. Obviously, because your computer doesn't have infinite memory, infinite throughput, and infinite code space, we know that there are theoretical maximums on everything, just like how there's a theoretical maximum number of lines of code you can have in a single jar.

But if you really really want to know the theoretical maximum number of interfaces a class can implement, it's 65535.