• Post Reply Bookmark Topic Watch Topic
  • New Topic

are members and fields the same thing?  RSS feed

 
jon ninpoja
Ranch Hand
Posts: 291
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was specifically told on this web site to refer to instance variables as fields

im reading oracles notes and came across this

"You control access to classes and members in the same way: by using an access modifier such as public in their declaration."

what are members? are members and fields the same?

but we call them fields...right?
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java® Language Specification (=JLS) tells you everything, but the JLS can be difficult to read. Members are fields, methods and included types (e.g. inner classes).
 
Knute Snortum
Sheriff
Posts: 4270
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was specifically told on this web site to refer to instance variables as fields 

What website was this?

I sometimes call them instance variables and sometimes fields.  On this site, I see instance variables more than fields.  I was taught that a field is an instance variable with a getter and setter, but I haven't heard that definition anywhere else.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:. . . What website was this? . . . I was taught that a field is an instance variable with a getter and setter, but I haven't heard that definition anywhere else.
It might have been me; I think I said it is better to call instance variables instance fields. I have never heard that a field includes getter and setter, only the variable. I thought field getter and setter together were called a property, but I don't think that is an official Java® term.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The Java Language Specification defines a field as either a static or instance variable. It is not specific to instance variables.

Henry
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the JLS say anything about constant fields? Or are those constant variables ‍?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!