What is the use of static import ?

Answer Posted / praveen kumar

The normal import declaration imports classes from packages, so that they can be used without package reference. Similarly the static import declaration imports static members from classes and allowing them to be used without class reference.

Now, we have got an excellent java feature from java 1.5. Ok now we shall see how we can abuse this!

Can i static import everything?
like, import static java.lang.Math.*; – yes it is allowed! Similarly you do for class import.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why scanner is used in java?

549


Can we have more than one package statement in the source file?

641


Can we create our own daemon thread?

541


Can a abstract class be defined without any abstract methods?

557


How can we pass argument to a function by reference instead of pass by value?

584






what is deadlock? : Java thread

525


What is a jagged array in java?

536


What is difference between overloading and overriding in java?

528


What is the numeric promotion?

496


Explain about arraylist?

575


What are the different types of data structures in java?

492


What if constructor is protected in java?

559


What is java Applet?

648


Write a function to print Fibonacci series and Tribonacci series?

757


How does sublist works in java?

542