The contacts are stored on your gmail account,this means your contacts are backed up to the cloud.
If you have not synced your contacts to the cloud you can do so by following the below
Go to settings scroll down to Accounts and sync and open it.
If you can see your gmail account tap on it,if not add your account or make a gmail account.
Click on contacts to sync them to the cloud.
Now if you get a new phone you can login to your gmail and your contacts will appear on your device.