How to create a Custom Service in Drupal 8

There are many services available in Drupal 8 by default, but sometimes we need to write our own function/logic and the functionality should be available throughout the Drupal 8 application. This can be achieved by creating a custom Service in …