Well using the * or the specific class will make a slight difference at the compile time and not at runtime.
When you are using *, during compilation the compiler tries to find the specific class whose function you are using and it then replaces * with classname. SO the class file doesn't contain any *. This option is given for the programmers convenience so that if he is using a number of classes from a package he need not specify import all the classes explicitly.
To understand better generate the class file for the given source file and check through some decompiler what changes the compiler has made.
source file - Test3.java
import java.util.*;
public class Test3
{
public static void main(
String[] args)
{
Date dd = new Date();
System.out.println(dd.getDate());
StringTokenizer st = new StringTokenizer("this is a test");
while (st.hasMoreTokens())
{
System.out.println(st.nextToken());
}
}
}
class file - Test3.class viewed through decafe (decompiler)
import java.util.*;
public class Test3
{
public static void main(String[] args)
{
Date dd = new Date();
System.out.println(dd.getDate());
StringTokenizer st = new StringTokenizer("this is a test");
while (st.hasMoreTokens())
{
System.out.println(st.nextToken());
}
}
}
I hope you must have understood it.
Parmeet