How to import classes with the same name in Java and how to rename the import

Asked 1 years ago, Updated 1 years ago, 96 views

At Python, from a import b as c It's like this when two imported cars collide. How do you do it in Java?

java import

2022-09-22 11:43

1 Answers

If the two imported classes have the same name, you can just use the class name You can write the full name of the class up to the package.

private ClassName obj1 = null;
private com.yourpackage.second.ClassName obj2 = null;

This is an example.


2022-09-22 11:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.