This is basic question but still i don\'t understand encapsulation concept . I did\'t understand how can we change the properties of class from other class.because whenever
Encapsulation means combining data and code together(class). The main purpose of encapsulation is you would have full control on data by using the code.
class Encap{
private int amount;
public void setAmount(int amount)
{
this.amount = amount;
}
Here, you can set the amount using the setAmount method, but value should be more than 100. So, i have the control on it.
public void setAmount(int amount)
{
if(amount>100)
this.amount = amount;
}