Differentiate "static" in Java and in C : <p>I am learning both Java and C sort of concurrently and when attempting to connect some common features of these two languages, I sometimes get a little bit confused. I try to identify the difference in "static" usage when in Java and in C and hope someone could point out whether my ways of understanding are correct. And is there any of my logic could be improved(Also want to know how you distinguish the usage of "static" in these two languages)?</p>

<p>So in C, "static" is used when you hope that some certain variables are only initialized once. And I think that's all.</p>

<p>For example:</p>

<pre><code>int main(void){
    for(int i=0;i&lt;=5;i++){
        static int x=35; //x is only initialized once
        x++;
        printf("%d ",x); //"36 37 38 39 40 41 "will be printed out 
    }
    x++; //This is not allowed as x is not a global variable.
    return 0;
}
</code></pre>

<p>But in Java, "static" is used when you hope some certain variables or methods can be accessed or called with the name of the class that holds the variables or methods, rather than some objects. And I think (usually, if not always?) you do "ClassName.SomeVariables" or ClassName.SomeMethods" in the driver class?</p>

<p>Therefore, is the usage of "static" in C and Java is very different? And a relevant question: how can the "static" in C be achieved by and features in Java?</p>

<p>Thanks in advance. ^_^</p>
