answersLogoWhite

0

Static means that something is done at compile time instead of when the object is instantiated, so you would therefore call a static method (doSomething()) through the class name rather than the object name.

class A{

public static void B(){

}

public void C(){

}

}

Let's say A instance = new A();

To access B you would say A.B(), while to access C you would say instance.C();

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

How do you invoke static methods?

if some method is static, then you can not call that method through the oobject of that class. but the name of the class. let us see a example: class Test { int a; int b; static void show() { System.out.println("we are in show"); } } class Main { public static void main(String args[]) { Test t=new Test(); t.show();\\thiss is an erroraneous code. because, the method "show()" is static. Test.show();\\this is correct } Arnas Sinha


Why do you use static key word in Java programming?

Static is a keyword,when u execute a method in class file loaded, execute the first this method..


What is native variable in java?

native is a key word used in java method. there is no variable as native in java


Why do you write void to the first of main?

Because main is the first method being executed, the Java Virtual Machine cannot expect any return values from this method. Since void is the term used to refer to a variable that does not return any value, we use the key word void for the method signature of the main method


How can you display Hindi word in output of java program?

Class hindi { public static void main() { char c; for(c=2309;c<2362;c++) { System.out.println(" "+c); } } }


What is fix in java?

fixed method means is one which cannot be overridden by a subclass. A fixed method can be declared by prefixing the word-final before a method. We can use the keyword final to donate a constant.


Where does the word Java originate from?

java


Write a Java Program to find occurences of given word in a text?

Check the documentation of the String class, for a method that searches for a substring.


How do you print a word before main function?

Do you mean something like this: static void Print (const char *s) { puts (s); } int main (void) { Print ("a word"); return 0; }


Advantages of static keyword in java?

When we want that a class member should be used independently of any object of that class, we have to precede that member's declaration with the keyword static .When a member is declared as static, it can be acccessed without creationg an object of the class and without referring to the object.That static is , a static member belons to a class as a whole and not to any one instance/object of that class.The static member is shared by all objects of thatclass.


What is the difference between nextLine and next method in scanner class java?

nextLine() reads a complete line while next() reads the next token ( a single word)


What does the word java mean?

Java is an island in Indonesia, but in slang it means coffee.