samar
Java static import
1 Answer(s)      2 years and 7 months ago
Posted in : Java Interview Questions

What is the use of static import ?
View Answers

October 30, 2010 at 11:17 AM


Hi,

Here is the answer,

The static import construct allows unqualified access to static members without inheriting from the type containing the static members. Instead, the program imports the members, either individually:

import static java.lang.Math.PI;

or en masse:

import static java.lang.Math.*;

Once the static members have been imported, they may be used without qualification:

double r = cos(PI * theta);

The static import declaration is analogous to the normal import declaration. Where the normal import declaration imports classes from packages, allowing them to be used without package qualification, the static import declaration imports static members from classes, allowing them to be used without class qualification.

Thanks.









Related Pages:
Java static import
Java static import  What is the use of static import
about static import - Java Beginners
to ask that "static import" syntax is correct or not package mypackage1... A { protected static int i=5; } package mypackage2; import static mypackage1.A....)TestABC.java import static mypack.TestA; public class TestABC { public static
static
static  what r the main uses of static in java   Hi Friend, The Static means that a certain object/variable is resident in memory... the following link: http://www.roseindia.net/help/java/s/static-java-keyword.shtml
static
is why if you declare the function main as static then java does not have...Static Concept  in what are all the situation we may use static...,then use static blocks and without creation of object we need to perform some task
static
static  What is the exact need of declaring a variable as static?   A static variable is a variable who's single copy in memory is shared by all objects,so any modifications to the static variable will modify it's value
Packages and Import
. It will add all necessary import statements. Static imports in Java 5 Java 5 added an import static option that allows static variables (typically constants... Java NotesPackages and Import Package = directory. Java classes can
The import keyword
. Java versions from J2SE 5.0 to upward can import the static members... The import keyword       The import statement make available one or all the classes in a package
Local Variable ,Package & import
; System.out.print(classVariable); } } Package & import Java classes can...Local Variable ,Package & import A local variable has a local scope.Such... Variable public class LocalVar { public static void main(String args
import file
import file    public void importFile(BlobDomain fileData) { InputStream inStr = fileData.getInputStream(); Workbook workbook... links: http://www.roseindia.net/tutorial/java/poi/readExcelFile.html http
static in java
static in java  what is the need to go static? what use
how to import user-define package to applet - Applet
how to import user-define package to applet  how to import user-define package to applet... can u write a java coding can execute in jdk only .... thx...  Hi friend, import java.applet.*; import java.util.
Static method
Static method  what is a static method?   Have a look at the following link: Java Static Method
static keyword
static keyword  Hii, In which portion of memory static variables stored in java. Is it take memory at compile time? thanks deepak mishra
Static Variable
Static Variable  What is the basic use of introducing static variable type in java?Please explain clearly....   The Static means...://www.roseindia.net/help/java/s/static-java-keyword.shtml
static functions
. For more information, visit the following links: Java Static Variables Java Instance Variables Java Static Method   Static Variables Static variables..., visit the following links: Java Static Variables Java Instance Variables
Static
/struts/struts2/strutsresources/static-parameter.shtml http://www.roseindia.net/java... Static       Static... an instance of a class. Static methods are implicitly final method, since overriding
Import attribute of page directive
Import attribute of page directive   How use import attribute of page directive ?   The import attribute is used to import all the classes in a java package into the current JSP page. If there are many Java packages
import package.subpackage.* does not work
("funA"); } } C.java:- import com.test.*; class C { public static...import package.subpackage.* does not work  I have 3 class files.... A a = new A(); ^ 2 errors But when instead of import
Import java IO - Java Beginners
Import java IO  for example i know java IO is for input and output. I am using Netbeans5.5.1. How can i see all the classes related to java IO for example; stream reader, buffer reader
Java static method
Java static method  Can we override static methods
import org.hibernate.Session error
import org.hibernate.Session error  I am new to hibernate. I have... the Eclipse project. 3. Started the Eclipse project and selected Java Project... are not included in the your project. Go to project properties-->Java Build Path -->
Static & Instance variables in java
Static & Instance variables in java  What are the Difference between Static & Instance variables in java
Static Method in Java
Static Method in Java  Is Overriding Static methods possible in java? If Yes, How
Import Data to SQL database in Java
Import Data to SQL database in Java  Hi, I'm a beginner and I'm wondering how to Import Data to SQL database in Java? Thanks (Platform: Eclipse/SQL
Java Import Statement Cleanup - Java Tutorials
Java Import Statement Cleanup 2002-06-18 The Java Specialists' Newsletter [Issue 051] - Java Import Statement Cleanup Author: Dr. Cay S. Horstmann... to receive training in Design Patterns. Java Import Statement Cleanup
class static - Java Beginners
information on Static in Java visit to : http://www.roseindia.net/java/beginners...class static  When do we declare a member of a class static?  Hi friend, public class HowToAccessStaticMethod{ int i; static int j
static & instance - Java Beginners
static & instance  what is different between static variable and instance variable .? plz explain with example. and when we can use static variable... { private static int noOfObjects; private int count; public Main
JSP import
JSP import         An import is the attribute of the page directive in JSP that imports the java packages and it's classes whenever required for the JSP page. More than
Java static method example
Description: Static variable are used within the static method. Non static variable do not exits in the static method. Static variables are shared by its class instances. Static variable can be used without using the instances
Static keyword in public static void main
Static keyword in public static void main  Hi, I have seen that on page mentioned below for static keyword explanation given is: Page: http://www.roseindia.net/java/learn-java-in-a-day/create-first-program.shtml Explanation
Import My Own Package (Automatically)
Import My Own Package (Automatically)   How can I import my own package in every java program ( automatically )....? For example :- java.lang.String... automatically imported, we need not to import
core java, static - Java Beginners
core java, static  Dear sir, in java non-static fields can not be accessed in a static field. But if we create an object of class type in static field and then call non-static field in it, it works fine as in following program
import user-define package - Applet
import user-define package  how to import user-define package... me ...  Hi friend, import java.io.*; import java.awt.*; import...://www.roseindia.net/java
how to inherit static variable
how to inherit static variable   how to inherit static variable or methods in Java?? Please explain the entire process of inheriting the variable. Thanks in advance
Static method in java - Java Beginners
Static method in java  What are static method in Java  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/howtoaccessstaticmethod.shtml Hope that it will be helpful for you
swing application to import a object in a excel
swing application to import a object in a excel  Hi sir, I want to make a swing application where I can import a object in a cell of a excel... no will be inside java code) then go to: 'insert' ribbon>select 'object'>select
How to import elglish dictionary in java - Java Beginners
How to import elglish dictionary in java  Hi.. This is Sakthi... How to import english dictionary in java platform.. My task it to check... .. Is it possible to do this in java
how to import english dictionary in java - Java Beginners
how to import english dictionary in java  Hi.. This is Sakthi... How to import english dictionary in java platform.. My task it to check whether... .. Is it possible to do this in java.... Thanks in advance
Static Method in java with realtime Example
Static Method in java with realtime Example  could you please make me clear with Static Method in java with real-time Example
STATIC
STATIC  WHAT IS STATIC BLOCK?EXPLAIN , AND WHAT IS THE DIFFERENCE BETWEEN STATIC BLOCK AND STATIC METHOD?   A STATIC block is automatically... between static block and static method: static block will execute when ever
static Java Keyword
static Java Keyword       The static is a keyword defined in the java programming language. Keywords... in java programming language likewise the static keyword indicates the following
A java application to import outlook calendar data
A java application to import outlook calendar data   Hi, I am Thamarai, i was allocated a task to create a java program to import outllok calander, As I am new to java can any one help me to complete my task
Static
Static  Can i know the real time example for Static method and final variables with defenition? Thank you
static
redeclare static variable in the inherited class  can we redeclare static variable in the inherited class like this: public class StaticClass1 { class StaticClass1{ static int noOfInstances; StaticClass1
Static final variables - Java Beginners
Static final variables  can a static final variable be accessed by a instance (non-static)method?  Hi, static final variable u can access in non-static method. but the variable should has accessibility, means
Import object in Excel using java swing
Import object in Excel using java swing  Hi sir, I want to make a swing application where I can import a object by clicking a button. I am using... in 'Insert' ribbon. first select a cell (cell no will be inside java code) then go
missing some import class(may be) - Java Beginners
missing some import class(may be)  Hi,Experts,I am a new one. I have made class in java,using netbeans 6.0.1 this getting error if i mouse over... shape.java", what i missed?   Hi, You have to change the java file name
Static Nested Classes
Static Nested Classes       A nested class that is declared static is called a static nested class. Memory to the objects of  any static nested classes are allocated
Static Parameter
Static Parameter       In this section, we will develop a simple application to access the static parameters. We will use a JavaBean to set and get the static parameters. Each static parameter has a value

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.