Praise be to Allaah.
Thinking about zinaa may mean one of two things.
(1)It may be merely thoughts that cross the mind, without becoming a firm resolve. A person cannot be blamed for this, but it is better to rid oneself of these thoughts so that they do not lead to anything else.
(2)It may be an established thought accompanied by resolve and intention. In this case, the person must hasten to deal with it in a number of ways, including the following:
1-Seriously thinking of getting married, because this is the shar’i (legal Islamic) and natural protection for the Muslim man and woman.
2-Fasting if one cannot get married.
3-Muslim men and women should strive to strengthen their eemaan (faith) by reading Qur’aan, praying naafil (voluntary) prayers and doing other kinds of acts of worship.
4-Taking care to choose righteous friends.
5-Keeping away from everything that might provoke desire; one of the most obvious of these is looking at things which are haram (impermissible).
6-Remembering the punishment for zinaa in this world and in the Hereafter, and that its evil affects far outweigh the immediate pleasure that a person may experience.