patternjavaCritical
Change Name of Import in Java, or import two classes with the same name
Viewed 0 times
withjavanamesamethechangetwoclassesimport
Problem
In Python you can do a:
How would you do this in Java, as I have two imports that are clashing.
from a import b as cHow would you do this in Java, as I have two imports that are clashing.
Solution
There is no import aliasing mechanism in Java. You cannot import two classes with the same name and use both of them unqualified.
Import one class and use the fully qualified name for the other one, i.e.
Import one class and use the fully qualified name for the other one, i.e.
import com.text.Formatter;
private Formatter textFormatter;
private com.json.Formatter jsonFormatter;Code Snippets
import com.text.Formatter;
private Formatter textFormatter;
private com.json.Formatter jsonFormatter;Context
Stack Overflow Q#2447880, score: 730
Revisions (0)
No revisions yet.