0

If I import a package and won't use the package, what are the consequences of the java application?

import java.util.ArrayList;

import java.util.HashMap;

import java.util.Map;

Above packages are used for my java application, the third package I never used.

kvk30
  • 1,133
  • 1
  • 13
  • 33

1 Answers1

1

You can use javap to check what happens.

Example class:

import java.util.ArrayList;

public class A {
    public static void main(String[] args) throws Exception {
        System.out.println("Test");
    }
}

compile the class and later run javap -v A - there is no difference, unused imports don't have impact on the class.

Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115