Share on Google+Share on Google+

about static import
1 Answer(s)      7 years ago
Posted in : Java Beginners


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:


package mypack;

public class TestA
public static int i=100;


import static mypack.TestA;

public class TestABC
public static void main (String [] arg) {
TestA testa = new TestA ();



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
About Static Class
About Static Class  is it neccessary to create object for static class
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  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  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  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  Can i know the real time example for Static method and final variables with defenition? Thank you
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
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 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" 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
in a subclass. To read more about static click at: Static       Static... an instance of a class. Static methods are implicitly final method, since overriding
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 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"); } } 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
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized


Advertisement null