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



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


vijay
class static
1 Answer(s)      6 years and 2 months ago
Posted in : Java Beginners



Advertisement
View Answers

November 26, 2008 at 5:45 AM


Hi friend,

public class HowToAccessStaticMethod{
int i;
static int j;
public static void staticMethod(){
System.out.println("you can access a static method this way");
}
public void nonStaticMethod(){
i=100;
j=1000;
System.out.println("Don't try to access a non static method");
}
public static void main(String[] args) {
//i=100;

j=1000;
//nonStaticMethod();
staticMethod();
}
}

For more information on Static in Java visit to :

http://www.roseindia.net/java/beginners

http://www.roseindia.net/tutorialsearch/?t=static

Thanks



Related Tutorials/Questions & Answers:
About Static Class
About Static Class  is it neccessary to create object for static class
Can a class be declared as static?
Can a class be declared as static?  Hi, Can a class be declared as static? thanks
Advertisements
class static - Java Beginners
class static  When do we declare a member of a class static?  Hi friend, public class HowToAccessStaticMethod{ int i; static int j; public static void staticMethod(){ System.out.println("you can access
Static database class - JSP-Servlet
Static database class  I want to create a static database class and i want to use that class in all servlets ? How can i achive
Java inner class and static nested class
Java inner class and static nested class  Java inner class and static nested class
What is the difference between a static and a non-static inner class?
What is the difference between a static and a non-static inner class?   Hi, What is the difference between a static and a non-static inner class? Thanks
What happens to the static fields of a class during serialization?
What happens to the static fields of a class during serialization?   What happens to the static fields of a class during serialization?   ... static fields, because they are not part of any particular state. Base class
Access Static Member Of The Class Through Object
Access Static Member Of The Class Through Object  ... that work without any object of the class. Static methods are limited to calling other static methods in the class and to using only static variables
STATIC
is an example: public class StaticTest { static{ System.out.println("Hello from...STATIC  WHAT IS STATIC BLOCK?EXPLAIN , AND WHAT IS THE DIFFERENCE BETWEEN STATIC BLOCK AND STATIC METHOD?   A STATIC block is automatically
static
instance of that object (the object that is declared static) in the 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
Squaring of two number in Static class
Squaring of two number in Static class  ...; . To square a static method  are define main class and passing the two... static method and how can display multiplication of two any number. The static
static
and accessed each time an instance of a class, an object, is created. When static... instances of the class. When static is applied to methods, the static keyword...static  what r the main uses of static in java   Hi Friend
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
Example of a class variable (static variable)
Example of a class variable (static variable)   ... you can define the static class variable in a class. When a number of objects... of a static variable first of all create a class StaticVariable. Define one 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 Nested Classes
; A nested class that is declared static is called a static nested class... independently of any particular outer class object. A static nested class use... an object reference. A static nested class interacts with the instance
Static
an instance of a class. Static methods are implicitly final method, since overriding depends on the type of the object, and static methods are attached to a class... Static       Static
Static variable in java
methods, variable inside a class and static class. Static variable is also called class variable which belongs to class not to object. Static.... Static variable is accessed without creating object of class using class name
static keyword in java
keyword in java programming language. A static member belongs to a class and is not linked with an instance of a class. We can use static keyword, static... the class name and do not need any object. Also in static method we can access
static functions
)It is a variable which belongs to the class and not to object(instance). 2)Static... variables. 3)A single copy to be shared by all instances of the class. 4)A static... object. Static Methods Static method is the method which belongs to the class
static keyword
Static Variables Static variables are class variables that are shared... instances of the class. 4)A static variable can be accessed directly by the class name... is the method which belongs to the class and not to the object(instance). 1)A static
Static Variable
of a class, an object, is created. When static is applied to member variables, it means that the static variable is shared among all instances of the class...Static Variable  What is the basic use of introducing static variable
PHP Static Variable and Methods
the all objects of that class. If we declare a method as static then we can access the method using class, without instantiating any object. Example of PHP Static Variables & Methods : <?php class One{ private static $var=0
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 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 keyword in public static void main
; The variable declared with static keyword is called class variable. This variable is shared by all the instances of the class. The static variable can be accessed... by all instance of the class. Example of static keyword: class UseStatic
 

 

 

DMCA.com