how to access private vairable in java method

Java
public Class A{

   private String myData;

   public String getMyData(){
        return myData;
   }

   public void setMyData(String data){
        this.myData=data;
   }
}
Source

Also in Java: