PDA

View Full Version : What is java static import?



priya01
05-20-2016, 04:06 AM
What is java static import?


itil service transition training (http://gogotraining.com/training/courses/240/itil-2011-service-transition--axelos-and-exin-accredited-training/) itil service operation training (http://gogotraining.com/training/courses/237/itil-2011-service-operation--axelos-and-exin-accredited-training/) itil service design training (http://gogotraining.com/training/courses/238/itil-2011-service-design--axelos-and-exin-accredited-training/) itil service strategy training
(http://gogotraining.com/training/courses/239/itil-2011-service-strategy--axelos-and-exin-accredited-training/)

tanhdavid
05-20-2016, 09:43 AM
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.

chrishbloom
05-21-2016, 04:17 AM
Static import is introduced in Java 5 along with other features like Generics, Enum, Autoboxing and Unboxing and variable argument methods.

web designer57
05-23-2016, 03:57 AM
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.

webdesign123
05-24-2016, 05:08 AM
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.

Sherin
04-08-2020, 07:51 AM
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

ishan_shah
04-10-2020, 02:55 AM
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.

RH-Calvin
04-10-2020, 04:19 AM
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.