Primitive type vs Reference type in Java
We all are familiar with variables, in java variables represent a memory location that hold a value. During declaration of a variables, you are telling the compiler that what kind of value the variable can hold. For example a primitive type or a reference type. The following figure illustrate the difference between the both types.

Fig 1. A variable of primitive type holds the value of a primitive type whereas reference type holds a reference of an object stored in memory
int i = 1; int j= 2; i=j;
Assigning the value of j to i, i is set the value of j having the same value as j have.
Let’s consider the class circle.
public class Circle { double radius; Circle(double r) { radius = r; } double getArea() { return radius * radius * Math.PI; } }
Creating two objects c1 and c2.
Circle c1 = new Circle(5.0); Circle c2 = new Circle(9.0); c1=c2;
In case of reference variable, assignment statement c1= c2. Reference variable c1 one updated. Now c1 and c2 are pointing the same memory location. It means c1 and c2 are holding the the same information as shown in fig 3.
I love what you guys tend to be up too. This sort of clever work and coverage!
Keep up the amazing works guys I’ve added you guys to my own blogroll.
my web-site translate online
thanks
I simply want to mention I’m beginner to blogging and really loved your website. Probably I’m likely to bookmark your blog post . You definitely have perfect article content. Many thanks for sharing your blog site.