How to use extension attribute in magento 2

Extension attributes are configured in a module’s etc/extension_ attributes.xml file. Extension attributes can be scalar values or objects. These attributes are compiled into an Extension class and interface.