The use of *
is considered a bad practice. It is used to import all files within that package. The more correct way of doing this is listing off each of the classes that you need, specifically in a scenario where you are doing a code review outside of an IDE and need to know which version of the class you are using. Essentially it breeds laziness in the development team.
Comment
For those arguing that this is not a "bad" practice as I have stated. How can you possibly say that this is a good practice?
import java.util.*;
import java.io.*;
Even if the compiler ignores everything under the *
except the List
that you have imported, how does this possibly help someone looking at the code in the future? I think a good deal of people here forget that you are writing code for humans and not the computer. Further how could you possibly convert this code when Java goes away and you are using SuperAwesomeLanguage? Given the following example please convert this to your new language when you have ZERO knowledge of java:
public class Foo
{
private List list;
}
Is List
in io
? is io
even required? The issue is you don't know. So by being explicit you can guide future developers as to what classes are required.