• Register
0 votes
23 views

Problem:

I have been told several definitions for it, looked on Wikipedia, but as a beginner to Java I'm still not sure what it means. Anybody fluent in Java?
public class Foo {
    public static void doStuff(){
        // does stuff
    }
}

So, instead of creating an instance of Foo and then calling doStuff like this:

9 5 4
12,970 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution:

What Is the Static Keyword in Java? 
In Java, a static part is an individual from a class that isn't related with an occurrence of a class. All things being equal, the part has a place with the class itself. Therefore, you can get to the static part without first making a class occasion. 

The two kinds of static individuals are static fields and static strategies: 

Static field: A field that is proclaimed with the static catchphrase, similar to this: 

private static int ballCount; 

The situation of the static catchphrase is compatible with the places of the perceivability watchwords (private and public, just as secured). Subsequently, the accompanying assertion works, as well: 

static private int ballCount; 

As a show, most developers will in general put the perceivability watchword first. 

The estimation of a static field is the equivalent over all cases of the class. At the end of the day, if a class has a static field named CompanyName, all articles made from the class will have a similar incentive for CompanyName. 

Static fields are made and introduced when the class is first stacked. That happens when a static individual from the class is alluded to or when a case of the class is made, whichever starts things out. 

Static strategy: A technique pronounced with the static catchphrase. Like static fields, static strategies are related with the class itself, not with a specific article made from the class. Accordingly, you don't need to make an article from a class before you can utilize static techniques characterized by the class. 

The most popular static strategy is fundamental, which is called by the Java

The most popular static strategy is fundamental, which is called by the Java runtime to begin an application. The principle strategy must be static, which implies that applications run in a static setting naturally. 

One of the fundamental standards of working with static strategies is that you can't get to a nonstatic technique or field from a static strategy in light of the fact that the static technique doesn't have an example of the class to use to reference occurrence techniques or fields.

7 3 3
24,200 points

Related questions

0 votes
1 answer 18 views
18 views
Problem: I want to know what does static mean in C# and why do we declare methods and variables as static in C#?
asked Oct 17, 2020 Code Learner 9.5k points
0 votes
1 answer 4 views
4 views
Problem: I will request someone to answer my question Please, I have searched on the web but I got no useful information for this, now I am in difficulty continuing my learning
asked Mar 22 sadi1982 36.3k points
0 votes
1 answer 91 views
91 views
Problem: % How Percent sign(%) acts as a modulus operator in java programming language?Modulus operator is an operator that works on integers and yields the remainder when one number is divided by another. Thus x = A%B means that x will carry the value of the remainder when dividing A by B.
asked Nov 6, 2020 Mashhoodch 13k points
0 votes
1 answer 22 views
22 views
Problem: IS != operator is a comparison operator,?where to used in conditional expressions. Isreads, “not equal”. If the compared values are not equal to each other than the expression returns true. An example of a program that uses both the && and !=
asked Nov 5, 2020 Mashhoodch 13k points
0 votes
1 answer 21 views
21 views
Problem: I am confused about operators in Java and unable to understand the use of *= operator. Kindly explain the working of *= in detail.
asked Oct 11, 2020 Code Learner 9.5k points
0 votes
1 answer 32 views
32 views
Problem: Hi there, I am new to the world of programming. I have a question that what does “/n” mean and what is its purpose?
asked Oct 10, 2020 Code Learner 9.5k points
0 votes
1 answer 3 views
3 views
Problem. Someone know why we write void in c++ code
asked Apr 10 Subhendu 4.5k points
0 votes
1 answer 6 views
6 views
Problem Anyone know where use double colon (::) operator in c++
asked Apr 10 Subhendu 4.5k points
0 votes
1 answer 4 views
4 views
Problem If i write in a function ‘*&’ , how its work or what will be output , if anyone knows the answar,please let me know
asked Apr 7 Subhendu 4.5k points
0 votes
1 answer 3 views
3 views
Problem How i will use && operator in c++ code
asked Mar 30 Subhendu 4.5k points