about static import

about static import

View Answers

August 25, 2009 at 4:34 PM

Hi Friend,

No,it is not correct.The class you are importing is not static.

Use public modifier instead of protected modifier in Class A with the variable i. By using public modifier,the variable will be accessible to any class of any package.

Try the following code:

1)TestA.java:

package mypack;

public class TestA
{
public static int i=100;
}

2)TestABC.java

import static mypack.TestA;

public class TestABC
{
public static void main (String [] arg) {
TestA testa = new TestA ();
System.out.println(testa.i);
}

}

Thanks









Related Tutorials/Questions & Answers:
about static import - Java Beginners
about static import  Hello Friend below program is not running when... to ask that "static import" syntax is correct or not package mypackage1... A { protected static int i=5; } package mypackage2; import static mypackage1.A.
Java static import
Java static import  What is the use of static import
Advertisements
About Static Class
About Static Class  is it neccessary to create object for static class
static
of the class that is initialized. Another thing about static objects is that you...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 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
static  what r the main uses of static in java   Hi Friend, The Static means that a certain object/variable is resident in memory and accessed each time an instance of a class, an object, is created. When static
Static
Static  Can i know the real time example for Static method and final variables with defenition? Thank you
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
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 keyword in java
.style1 { color: #0000FF; } static keyword in java We are going to discuss about static keyword in java. The static keyword is a special keyword in java programming language. A static member belongs to a class
Static Resources Configuration
In this section, you will learn about Static Resources Configuration through MVC Java config and XML Namespace
Local Variable ,Package & import
Local Variable ,Package & import A local variable has a local scope.Such... Showing Local Variable public class LocalVar { public static void main... ClassVar { private static int classVariable; public static void main(String args
Static Parameter, Static Parameter in Struts 2, Struts 2 Static Parameter
the three static parameters by using the setParameter1(), setParameter2...;} } Create a jsp page(showparameters.jsp) to view the static parameters. ... a table that contains three static parameters in key-value format . Output
static keyword
static keyword  please give some detail about Static keyword.   Static Variables Static variables are class variables that are shared... and not to object(instance). 2)Static variables are initialized only once , at the start
Static
in a subclass. To read more about static click at: ADS_TO_REPLACE_1 http... Static       Static... an instance of a class. Static methods are implicitly final method, since overriding
"import" Attribute of page directive
will discuss about the "import" attribute of a JSP & its use in JSP page. A directive element in a JSP page provides global information about a particular JSP page. Page directive attributes that notify the Web container about
PHP Late Static Binding
PHP Late Static Binding: A new feature called late static binding... static binding is coined because of the static:: will no longer be resolved using... class One {ADS_TO_REPLACE_2 public static function classIdentifier() { echo
static in java
static in java  what is the need to go static? what use
Static method
Static method  what is a static method?   Have a look at the following link: Java Static Method
static methods
static methods  why static methods cannot read or write the instance variables
static method
static method  Give some absolute examples and definition for static method also
static functions
static functions  Give some brief defenition for 1. Static Variables 2. Static Functions 3. Instance Variable  Static Variables Static...)It is a variable which belongs to the class and not to object(instance). 2)Static
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... of a class, an object, is created. When static is applied to member variables
import file
import file    public void importFile(BlobDomain fileData) { InputStream inStr = fileData.getInputStream(); Workbook workbook = Workbook.getWorkbook(inStr); Sheet sheet = workbook.getSheet(0); int colCount
static keyword in interface
static keyword in interface  Could any one explain,why static keyword implict (or explict ) come in interface? I asked lot of persons about this question, but nobody did not answered clearly. please explain clearly and say what
About java
About java   how we insert our database data into the jTable in java... in java   Hi Friend,ADS_TO_REPLACE_1 Try the following code: import java.io.*; import java.awt.*; import java.sql.*; import java.util.*; import
static
about form
about form  how to dynamically increase the textbox in the 2nd form... , totally 5textbox have to be created in form2.   import javax.swing.*; import java.io.*; import java.awt.*; import java.util.*; import
What is static factory pattern?
What is static factory pattern?  Hello, please tell me what is static factory pattern? Thank you..   Dear friend, you can go through the following links to better understand the static factory pattern - Factory
About BufferedReader
file. import java.io.*; class Modify { public static void main(String...About BufferedReader   I have created FileInputStream fstream... seek() method of RandomAccessFile class. import java.io.*; public class
demonstrate a) static data members b) static methods
demonstrate a) static data members b) static methods  demonstrate a) static data members b) static methods
About struts
About struts  How will we configure the struts
About Java
About Java  Hi, Can anyone tell me the About Java programming language? How a c programmer can learn Java development techniques? Thanks   Hi, Read about java at http://www.roseindia.net/java. Thanks
About jsp
About jsp  Read Excel data using JSP and update MySQL databse
about java
about java  how to get the value from the user like c, c++ program pls explain with example for me
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
PHP set static Method
_set_static()Method in PHP : In this tutorial we will study how to assign values of an object to another object dynamically. To do this we use __set_static() method. We need to declare a magic method called __set_static() which
about interface - Java Beginners
about interface  can anyone explain to me the implementation..., import java.util.*; import java.io.*; public class SetHashset{ public static void main(String args[]){ Set set = new HashSet(); Set dups = new HashSet
about jquery
about jquery  i want to put already made dropdown menu code which is in internet into my website.but how to put
static keyword with real example
static keyword with real example  static keyword with real examplestrong text
Java static method
Java static method  Can we override static methods
why using static keyword
why using static keyword  why using static keyword
about java - Java Beginners
about java  hello, being a begineer in Java i would like know... from the command prompt. import java.util.*; public class UserInput{ public static void main(String[]args){ System.out.println("Enter number
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...: static keyword indicates that this method can be invoked simply by using the name
About Java2
About Java2  sir i want to a develop one text editor but the problem is that i m not able to save our file as text formet or any formet Sir plz guide me
about java1
about java1  Sir, i want to know how we develop 3d button ,lable,textfield etc. in java . sir plz give one program as well Thank you
ABOUT Jtable
ABOUT Jtable  My Project is Exsice Management in java swing Desktop Application. I M Use Netbeans & Mysql . How can retrive Data in Jtable from Mysql Database in Net Beans
About Main
About Main  can u create the object of one interface ? But i can able to create the abstract class through anonimous inner class.similarly can i
About Main
About Main  can u create the object of one interface ? But i can able to create the abstract class through anonimous inner class.similarly can i

Ads