A mutable object can be changed after it's created, and an immutable object cant.

In Java, everything(except for strings) is mutable by default

Mutable object- You can change states and fields after the object is created for example: StringBuilder, java.util.Date and etc.

Immutable object- you can not change anything after object is created For examples: String boxed primitive objects like,IntegerLong and etc.


Java mutable example: 

Normally, it provides a method to modify the field value, and the object can be extended.

public class MutableExample{ 

private String name;

MutableExample(String name){

this.name = name;

}

public String getName(){

return name;

}

public void setName(String name){

this.name = name;

}

public static void main(String args[]){

MutableExample obj = new MutableExample("pkyong");
System.out.println(obj.getName());

//update the name, this object is mutable
obj.setName("new pkyoung");
System.out.println(obj.getName());
}
}

Output:
pkyong 
newpkyong  


2. Java Immutable Example

To create an Immutable object, make the class final, and don’t provide any methods to modify the fields.
public class final ImmutableExample{

private String name;

ImmutableExample(String name){

this.name = name;

}

public String getName(){

return name;

}

public static void main(String args[]){

ImmutableExample obj = new ImmutableExample("pkyong");

System.out.println(obj.getName());

}
}

Output: pkyong