Variable vs Object vs Reference

Variables, Objects and References, we frequently listen to these terms while development but usually gets confused between them.

This post was originally posted at and reposted on Medium on 4th Dec 2020.

Let’s try to understand a very basic definition along with an example for all three. The concept is similar in any object-oriented programming language but for reference, I’ll be using Java examples. Feel free to comment below if you need examples in any specific language.


Name storage means we (developers) define the name of the variable.
Primitive data types are something which predefined in any language like int, float, boolean etc.
Keep in mind Int with the capital I or Float with the capital F are not primitive data types, those are non-primitive data types.
The size of the variable depends on the type of it.
In Java, a char takes 2 bytes, int takes 4 bytes, float takes 8 bytes and so on.

int age = 5;
float pi = 3.14;


Please continue reading at

That’s all for now. You can read my other interesting posts here or you can enjoy my games or apps listed here. Feel free to use my open-source Android components in your app listed here. Or drop an email, if you didn’t find what you are looking for and need some help.