core java, static

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 ( Ultimately this is what we do in static main method). So is right to say that practically its not impossible to call non-static fields in static fields.

//Static.java
public class Static
{

static void stat()
{
Static st1 = new Static();
st1.stat1();
}

void stat1()
{
System.out.println("You can call me within static method with the help of class object");

}


public static void main(String args[])
{
Static st1 = new Static();

st1.stat();

}
}
View Answers

August 10, 2010 at 4:09 PM

Hi Friend,

Yes, it is right.

Thanks









Related Tutorials/Questions & Answers:
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
static in java
static in java  what is the need to go static? what use
Advertisements
Maven dependency for com.17jee - e-core-static version 3.0.1.10 is released. Learn to use e-core-static version 3.0.1.10 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.10 ) in their Java project... that downloads and includes  com.17jee - e-core-static version 3.0.1.10 java library...Maven dependency for  com.17jee  - Version 3.0.1.10 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.1.7 is released. Learn to use e-core-static version 3.0.1.7 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.7 ) in their Java project... and includes  com.17jee - e-core-static version 3.0.1.7 java library in your...Maven dependency for  com.17jee  - Version 3.0.1.7 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.0 is released. Learn to use e-core-static version 3.0.0 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.0 ) in their Java project...; com.17jee - e-core-static version 3.0.0 java library in your project. ADS...Maven dependency for  com.17jee  - Version 3.0.0 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.0.RELEASE is released. Learn to use e-core-static version 3.0.0.RELEASE in Maven based Java projects
- e-core-static version 3.0.0.RELEASE in Java projects. Follow the step by step...-static released The developers of   com.17jee - e-core-static project... version of  com.17jee - e-core-static library is 3.0.0.RELEASE. Developer
Maven dependency for com.17jee - e-core-static version 3.0.1.0 is released. Learn to use e-core-static version 3.0.1.0 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.0 ) in their Java project... and includes  com.17jee - e-core-static version 3.0.1.0 java library in your...Maven dependency for  com.17jee  - Version 3.0.1.0 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.1.1 is released. Learn to use e-core-static version 3.0.1.1 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.1 ) in their Java project... and includes  com.17jee - e-core-static version 3.0.1.1 java library in your...Maven dependency for  com.17jee  - Version 3.0.1.1 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.1.2 is released. Learn to use e-core-static version 3.0.1.2 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.2 ) in their Java project... and includes  com.17jee - e-core-static version 3.0.1.2 java library in your...Maven dependency for  com.17jee  - Version 3.0.1.2 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.1.3 is released. Learn to use e-core-static version 3.0.1.3 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.3 ) in their Java project... and includes  com.17jee - e-core-static version 3.0.1.3 java library in your...Maven dependency for  com.17jee  - Version 3.0.1.3 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.1.11 is released. Learn to use e-core-static version 3.0.1.11 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.11 ) in their Java project... that downloads and includes  com.17jee - e-core-static version 3.0.1.11 java library...Maven dependency for  com.17jee  - Version 3.0.1.11 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.1.9 is released. Learn to use e-core-static version 3.0.1.9 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.9 ) in their Java project... and includes  com.17jee - e-core-static version 3.0.1.9 java library in your...Maven dependency for  com.17jee  - Version 3.0.1.9 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.1.8 is released. Learn to use e-core-static version 3.0.1.8 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.8 ) in their Java project... and includes  com.17jee - e-core-static version 3.0.1.8 java library in your...Maven dependency for  com.17jee  - Version 3.0.1.8 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.1.5 is released. Learn to use e-core-static version 3.0.1.5 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.5 ) in their Java project... and includes  com.17jee - e-core-static version 3.0.1.5 java library in your...Maven dependency for  com.17jee  - Version 3.0.1.5 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.1.4 is released. Learn to use e-core-static version 3.0.1.4 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.4 ) in their Java project... and includes  com.17jee - e-core-static version 3.0.1.4 java library in your...Maven dependency for  com.17jee  - Version 3.0.1.4 of e-core-static
Maven dependency for com.17jee - e-core-static version 3.0.1.6 is released. Learn to use e-core-static version 3.0.1.6 in Maven based Java projects
this version ( com.17jee - e-core-static version 3.0.1.6 ) in their Java project... and includes  com.17jee - e-core-static version 3.0.1.6 java library in your...Maven dependency for  com.17jee  - Version 3.0.1.6 of e-core-static
Java static import
Java static import  What is the use of static import
Java static method
Java static method  Can we override static methods
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
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
Version of com.17jee>e-core-static dependency
List of Version of com.17jee>e-core-static dependency
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 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
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 & 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
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 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
Static  Can i know the real time example for Static method and final variables with defenition? Thank you
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
Maven Dependency e-core-static >> 3.0.0
You should include the dependency code given in this page to add Maven Dependency of com.17jee >> e-core-static version3.0.0 in your project
Maven Dependency e-core-static >> 3.0.1.1
You should include the dependency code given in this page to add Maven Dependency of com.17jee >> e-core-static version3.0.1.1 in your project
Maven Dependency e-core-static >> 3.0.1.4
You should include the dependency code given in this page to add Maven Dependency of com.17jee >> e-core-static version3.0.1.4 in your project
Maven Dependency e-core-static >> 3.0.0.RELEASE
You should include the dependency code given in this page to add Maven Dependency of com.17jee >> e-core-static version3.0.0.RELEASE in your project
Maven Dependency e-core-static >> 3.0.1.0
You should include the dependency code given in this page to add Maven Dependency of com.17jee >> e-core-static version3.0.1.0 in your project
Maven Dependency e-core-static >> 3.0.1.2
You should include the dependency code given in this page to add Maven Dependency of com.17jee >> e-core-static version3.0.1.2 in your project
Maven Dependency e-core-static >> 3.0.1.3
You should include the dependency code given in this page to add Maven Dependency of com.17jee >> e-core-static version3.0.1.3 in your project
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
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 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
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for e-core-static version 3.0.0
-core-static:3.0.0 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static version 3.0.0..., Grape, Leiningen and  Buildr Dependency for e-core-static version 3.0.0. You
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for e-core-static version 3.0.1.1
-core-static:3.0.1.1 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static version 3.0.1.1..., Grape, Leiningen and  Buildr Dependency for e-core-static version
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for e-core-static version 3.0.0.RELEASE
com.17jee:e-core-static:3.0.0.RELEASE Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static... for the  e-core-static version 3.0.0.RELEASE just by copying and pasting your
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for e-core-static version 3.0.1.11
:e-core-static:3.0.1.11 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static version..., Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static version
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for e-core-static version 3.0.1.10
:e-core-static:3.0.1.10 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static version..., Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static version
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for e-core-static version 3.0.1.9
-core-static:3.0.1.9 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static version 3.0.1.9..., Grape, Leiningen and  Buildr Dependency for e-core-static version
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for e-core-static version 3.0.1.8
-core-static:3.0.1.8 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static version 3.0.1.8..., Grape, Leiningen and  Buildr Dependency for e-core-static version
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for e-core-static version 3.0.1.7
-core-static:3.0.1.7 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static version 3.0.1.7..., Grape, Leiningen and  Buildr Dependency for e-core-static version
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for e-core-static version 3.0.1.6
-core-static:3.0.1.6 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static version 3.0.1.6..., Grape, Leiningen and  Buildr Dependency for e-core-static version
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for e-core-static version 3.0.1.5
-core-static:3.0.1.5 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for e-core-static version 3.0.1.5..., Grape, Leiningen and  Buildr Dependency for e-core-static version

Ads