Home Answers Viewqa Java-Beginners about static import

 
 


sachin
about static import
1 Answer(s)      3 years and 9 months 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:

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 Pages:
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
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
About Static Class
About Static Class  is it neccessary to create object for static class
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
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... import static java.awt.Color; It would then be possible to write Color
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
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
About java
About java   how we insert our database data into the jTable in java... in java   Hi Friend, Try the following code: import java.io.*; import java.awt.*; import java.sql.*; import java.util.*; import javax.swing.*; import
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
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
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
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
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..." series. Cay very kindly pointed me to an article that he wrote about a tool he
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
"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
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 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
how to import user-define package to applet - Applet
how to import user-define package to applet  how to import user... .... thx...  Hi friend, import java.applet.*; import java.util.*; import java.awt.*; import java.util.Calendar; import java.text.SimpleDateFormat
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 Resources Configuration
In this section, you will learn about Static Resources Configuration through MVC Java config and XML Namespace
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 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
about swing - Java Beginners
about swing  how implement a program of adding two numbers... AddNumbers{ public static void main(String[] args) { System.out.println...: " + sum); } }   Hi friend, import javax.swing.*; import
about linked list
about linked list   hey can u help me soon ?? i want to add student... mark above 60 and average ,,,also i want to search about someone student thats in linked list   import java.util.*; class StudentData{ int id
About jcombobox - Swing AWT
About jcombobox  Hi all, I am new to this forum. Can we do auto...: import java.awt.*; import java.awt.event.*; import java.util.*; import...); } return m; } public static void main(String[] args
Spting AOP Static Pointcut
.style1 { background-color: #FFFFCC; } Static Pointcut Static...; import org.aopalliance.intercept.MethodInterceptor; import...; } } SimplePointCut.java package roseindia.net.pointcut; import
About java and JDBC
About java and JDBC  Hello sir, I am doing project on java... in this regard. Thanks & Regards Pradeep CBZ   import java.awt.*; import java.sql.*; import java.awt.event.*; import javax.swing.*; class DatePicker
About java and JDBC
About java and JDBC  Hello sir, I am doing project on java... in this regard. Thanks & Regards Pradeep CBZ   import java.awt.*; import java.sql.*; import java.awt.event.*; import javax.swing.*; class DatePicker
about java swing - Java Beginners
about java swing   How to upload the pictures and photo on the panel... the following code: import java.awt.*; import java.io.*; import javax.swing.*; import java.awt.image.*; import java.awt.event.*; import javax.imageio.ImageIO
Calling Static Methods Using SpEL
Calling Static Method Using SpEL Spring 3 provides powerful Expression Language which can be used to wire values into beans properties by calling static...-beans.xml: We will see how to use static method random() of java.util.Math class
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 java swing - Java Beginners
the following code: import java.sql.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; public class GetDOB{ public static void main...about java swing   How to send date in data base if i use
Access Static Member Of The Class Through Object
Access Static Member Of The Class Through Object       Static methods are special type of methods that work without any object of the class. Static methods are limited to calling
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
Understanding public static void main function
. Read more about public static void main function at http://www.roseindia.net... Understanding public static void main function       The public static void main function is important
About MYSQL
About MYSQL  is it possible to upload the video on mysql database...; </HTML> 2)upload.jsp: <%@ page import="java.io.*" %> <%@ page import="java.sql.*" %> <%@ page import="java.util.zip.*"%> <% String
please help me to solve this question about array
import java.util.Scanner; public class Example1 { public static void main...please help me to solve this question about array  write a program...) and determine whether the entered character is vowel or not.   import
About JSP Expression Language - JSP-Servlet
About JSP Expression Language   Hi i am new to JSP i am now going...!In your code you have defined the function in static format and anything, which is written in static, will print the value as it is given.In your code you have
Explain about threads:how to start program in threads?
Explain about threads:how to start program in threads?  import java.util.*; class AlphabetPrint extends Thread { public void print...(); } } class AlphaNumericPrint { public static void main(String[] args
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
About zodiac sign in java - Java Beginners
About zodiac sign in java  Hello again.. I need help.. Our assgnment... the following code: import java.util.*; public class ZodiacSign { public static void main(String[] args) { String sign=""; String element
static method
static method  Give some absolute examples and definition for static method also
static methods
static methods  why static methods cannot read or write the instance variables

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.