3

Is there any difference between using

public ClassName extends some.package.Class implements another.package.Interface {}

and

import some.package.Class;
import another.package.Interface;

public ClassName extends Class implements Interface {}

when talking about performance, compatibility, etc..

Marek Sebera
  • 39,650
  • 37
  • 158
  • 244

2 Answers2

4

There is no difference. The byte code is identical. All this happens at compile time, there is zero performance impact. You should make this decision based solely on your evaluation of readability.

user207421
  • 305,947
  • 44
  • 307
  • 483
1

It's a compile-time feature, so it's related to performance by no means. From compatibility standpoint, the only idea is that if you have 2 packages with classes named Entity and there's a module where you'd like to use both of them, having import ... means only one of these entities would be available using it's unqualified name. But it's more to maintenance than to compatibility.

Andrey Agibalov
  • 7,624
  • 8
  • 66
  • 111