In C we can write:
#define LOWER 0
And in Java we can write:
static int lower = 0;
Don't these statements have the same purpose of letting other methods use the variable lower?
Is is what is known as a state of being verb. State of being verbs do not express any specific activity or action but instead describe existence. The most common state of being verb is to be, along with its conjugations (is, am, are, was, were, being, been).
Or is a conjunction that connects two or more possibilities or alternatives. It connects words, phrases and clauses which are the same grammatical type: Which do you prefer? Leather or suede? You can have some freshly baked scones or some chocolate cake or both.
Definition of in use : being used All of the computers are currently in use.
From Middle English is, from Old English is, from Proto-West Germanic *ist, from Proto-Germanic *isti (a form of Proto-Germanic *wesaną (“to be”)), from Proto-Indo-European *h₁ésti (“is”).
They are totally different. Define is more of a copy paste that the C preprocessor uses. Static is an attribute modifier for a Java class. A static attribute can be changed at runtime.
#define
in C causes textual substitution. For example:
#define PI 3.14
...
a = PI * r * r; // becomes: a = 3.14 * r * r
Now, the scope of #define
is much larger than that; it isn't only limited to variables (and there isn't something directly equivalent in Java). When you have a static
variable, there is no guarantee that that variable will not change, so a similar "textual substation" cannot be made. However, when you declare a static final
variable and assign it to a compile-time constant, there is such a guarantee. So:
public static final double PI = 3.14;
...
a = PI * r * r; // becomes: a = 3.14 * r * r, like in C
Much like what happened with #define
, static final constants are replaced with their actual values at compile time. In this sense, static final constants are similar to #define
constants.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With