Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

class member definition in java

Tags:

java

I recently encountered this phrase:

"Class A has class member int a"

Probably obvious but this sentence just means a is an int defined in class A, right?

And another thing, for example a is defined under a method in class A. is it still a class member?
I haven't found a clear definition of class member, I looked here: but it wasn't very helpful.

Thank's in advance for the help

like image 376
Octo Avatar asked Jun 04 '26 22:06

Octo


2 Answers

Class member is another way of calling static members.

class A {
    int a; //instance variable
    static int b; //class variable
    public void c() {
        int d; //local variable
    }
}
like image 72
assylias Avatar answered Jun 06 '26 12:06

assylias


In same docs

Fields that have the static modifier in their declaration are called static fields or class variables

Class variables are referenced by the class name itself, as in

Bicycle.numberOfBicycles

This makes it clear that they are class variables.

like image 40
Suresh Atta Avatar answered Jun 06 '26 12:06

Suresh Atta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!