0

I'm very new to java I need to use a different features from MAVEN dependencies but they have a same name like this,

import java.nio.file.Files;
import com.google.common.io.Files;

I do not allow me to import. I will throw error like

The import com.google.common.io.Files collides with another import statement

Can this be solved ? Thanks a lot.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224
Hikaru Shindo
  • 2,611
  • 8
  • 34
  • 59

1 Answers1

0

When you have to use two classes with the same name, you have to import one and use the fully qualified name of the other one in the code.

For example, leave the first import. And when you want to create one variable of each type, you do the following:

import java.nio.file.Files;

public class MyClass{

    Files files; //This variable uses the imported type
    com.google.common.io.Files ioFiles; //This variable uses the explicit type
}
Andres
  • 10,561
  • 4
  • 45
  • 63