What is java static import?
itil service transition training itil service operation training itil service design training itil service strategy training
What is java static import?
itil service transition training itil service operation training itil service design training itil service strategy training
Static import is a feature introduced in the Java programming language that allows members (fields and methods) defined in a class as public static to be used in Java code without specifying the class in which the field is defined. This feature was introduced into the language in version 5.0.
Static import is introduced in Java 5 along with other features like Generics, Enum, Autoboxing and Unboxing and variable argument methods.
The static import feature of Java 5 facilitate the java programmer to access any static member of a class directly. There is no need to qualify it by the class name.
Static import is a feature introduced in the Java programming language that allows members (fields and methods) defined in a class as public static to be used in Java code without specifying the class in which the field is defined.
As import statement allows to use a class without its package qualification, static import allows to access the static members of a class without class qualifications.
To understand this topic, you should have the knowledge of packages in Java. If you hate to type same thing again and again then you may find such imports interesting.
For Example, to access the static methods you need to call the using class name
Math.sqrt(169);
But, using static import you can access the static methods directly.
Example
import static java.lang.Math.*;
public class Sample{
public static void main(String args[]){
System.out.println(sqrt(169));
}
}
Output
13.0
hello,priya
static import is use to access the static method of a class without using full class name.
As import statement allows to use a class without its package qualification, static import allows to access the
static members of a class without class qualifications.For Example, to access the static methods you need to
call the using class name.
static import is use to access the static method of a class without using full class name
if you write a code with lot of mathematical calculations so you may to use static import.
like Math.sqrt(289);
I hope this'll help you.
Static import is a feature introduced in the Java programming language that allows members (fields and methods) which have been scoped within their container class as public static , to be used in Java code without specifying the class in which the field has been defined.
█ Cheap VPS | $1 VPS Hosting
█ Windows VPS Hosting | Windows with Remote Desktop
█ Cheap Dedicated Server | Free IPMI Setup
|
Bookmarks