Saturday, August 28, 2010

Static Imports

We use "imports" in java so that in order to refer classes we don't have to use fully qualified name. Similar, static imports are used so that we don't have to use classname to call a static method. e.g. java.lang.String class contains a lot of static methods, so you can import this class statically and later on in the code just use method name to use it without mentioning "String" class name. Static imports are usually used when you are using a class's static methods repeatedly.

No comments:

Post a Comment