Java Java Objects Meet Objects Methods

What is the difference here between a field and an object? You seem to be using them interchangeably.

What is the difference here between a field and an object? You seem to be using them interchangeably.

Andrew Crossley
Andrew Crossley
6,244 Points

An object is an item in the real world. e.g a physical box, a physical cup. A field can be a variable called "cup" which relates to the real world object.

1 Answer

Field is just another name used for variable. Object is something completley else and to understand it let's use an analogy. If you think of a car you have the enginge which is an object. The engine has many diffrernt functions like ignite and turn of the car. In the same way object in codes has different objects to perform different functions. Mark this answer if understood. : )