What does "values", "data" and "field" mean in java ?

For example, definition of encapsulation is hiding of data in a class and making this class available only through methods. In this way the chance of making accidental mistakes in changing "values" is minimized.

In access specifiers, Java allows us to control access to classes, methods, and "fields" via so-called access specifiers.

Please anyone explain that what does values and fields mean and does data means code in java ??

Recommended Answers

All 2 Replies

Can you get definitions from Google for these terms and post them here for us to chose which ones make sense in the java programming environment?

Those 3 terms are all very similar, and people will use them almost interchangeably. But here's my attempt to distinguish the main uses of them, while ignoring some of the more obscure exceptions:
Data is everything that's not executable code. It's the ints, booleans, bytes, Strings, arrays etc that a program uses and creates, eg 101, "James".
A value is the data associated with a variable or field, eg String personName = "James" ... the data "James" is the value of the variable personName.
Field is a word from the Object-Oriented world. When you define a class it has methods and fields. Fields will typically be implemented as variables in the class (but not necessarily - that's what data hiding is about), and accessed via public setter and getter (mutator and accessor) methods. Fields have values, which are examples of data.
Does that help?
Maybe someone else can explain it better...

ps. Yes, I deliberately didn't talk about references to objects; first things first, time enough for that later.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.