1
    import java.util.ArrayList;
    import java.util.Collections;   
    ...   

or

import java.util.*;   

Is there any execute time difference according to usage ?
Which one should I prefer to use?

ZpCikTi
  • 341
  • 6
  • 17

1 Answers1

-1

If you use

import java.util.ArrayList; import java.util.Collections;

or

import java.util.*;

They both result to same byte code after compilation. There is no execution time difference. But you should prefer the first option as it will helps you if two or more packages have same Class File name.

for example if java.xyz and java.abc, both packages have class Sample and if you import both packages directly in your class then compiler will raise error and asks to resolve the ambiguity

  • the compiler will tell upfront if there is any ambiguity and to correct that error one has to use the FQCN(fully qualified class name). – Priya Jain Jan 22 '18 at 11:45