Auto update app from Play Store

How to make such type of of which can update automatically from Play Store whenever a new version of that app uploaded on Play Store like amazon, whatsapp etc. Such app don’t ask user or take permission from user to update the app through play store. It update itself silently whenever new version of app is available on play store.

Check the hotstar app. It is the best example where user is just asked if he wants to update the app.

I want to know Java code / program for this.

I dont have the code for this. You have to implement it yourself.