Fieldset is a group of fields which can then be used in visualforce page or apex code. You have to only drag and drop the fields in a fieldset just like a page layout.
By accessing fields from a fieldset your code becomes dynamic as you can remove or add the fields by simply modifying the fieldset and there is no need to modify the code.
You can see how we can access fields directly in a visualforce page Here
Let us see how we can access the fields of a fieldset in a apex code.
First lets create a fieldset on contact and name it as "ContactFieldset".
Include fields by dragging and dropping in the area as shown in below screen shot. Have included three fields (Email, email Optout and department)
Following piece of code forms a query using filed api names fetched from the fieldset on contact.
Output of the debug statement is as shown below(it forms a proper query taking all the fields which were included in the fieldset)
Article 1** Article 2** Article 3** Article 4** Article 5** Article 6** Article 7** Article 8** Article 9 ** Article 10