Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners about static import
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sachin
about static import
1 Answer(s)      5 years and 4 months ago
Posted in : Java Beginners



Advertisement
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  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
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
Local Variable ,Package & import
Local Variable ,Package & import A local variable has a local scope.Such... Variable public class LocalVar { public static void main(String args... the Class Variable public class ClassVar { private static int
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
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
"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
Static Parameter, Static Parameter in Struts 2, Struts 2 Static Parameter
the three static parameters by using the setParameter1(), setParameter2... a jsp page(showparameters.jsp) to view the static parameters.  ... that contains three static parameters in key-value format . Output of this application
Static
in a subclass. To read more about static click at:  http://www.roseindia.net... Static       Static... an instance of a class. Static methods are implicitly final method, since overriding
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 Resources Configuration
In this section, you will learn about Static Resources Configuration through MVC Java config and XML Namespace
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... { public static function classIdentifier() { echo __CLASS__; } public static
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 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
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
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
Problem of Import JWorkbook
Problem of Import JWorkbook  Hi... i can't use the jworkbook in my project.what types of library files in import
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... that the JSP page wants to import, the programmer can use import more than once
import package - JSP-Servlet
import package  how to import a package into a jsp page...pls reply with an example..  Hi friend, To import a package in Jsp use the import Attribute of page Directive In JSP The package name folder is putted
jfree missing import file
jfree missing import file  hi....... i have checked the jar file of jfree that import file of RECTANGLEINSETS is not there then what to do now? how to solve this problem? plz help?   Download jcommon-1.0.16.jar
Advertisements
 

 

 

DMCA.com