It’s the duty of Muslims, males and females, to abide by the dictates of morality and decency everywhere. In public transports men should avoid coming into close contact with women.
Sheikh Ahmad Kutty, a senior lecturer and an Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states: In situations, one must consider whether they have any other options to take in order to avoid such close encounters with members of the opposite sex: Consider the possibility of changing your work hours, or changing your route to work, or even changing the time of travel by preferring to travel in less crowded times. If any of the above options are available, you must try it out.

If, however, we are faced with no reasonable option, then such person may travel, provided they do everything possible to shift their focus away from thinking of the members of the opposite sex. Concentrate on Dhikr and Istighfar and discipline your mind in such a way that it would not make a difference for you whether you are standing beside a piece of furniture or a member of the opposite sex.
By doing your best to do what is within your means and ability, you have fulfilled your religious duty, the rest is with Allah. Allah reassures us in the Qur’an, (Allah does not impose on anyone a duty that he has no strength to bear.) (Al-Baqarah 2: 286) We are told to fear Allah as best as we can.
Finally, continue to seek Allah’s help in guarding yourself against temptations of all kinds. Allah says, (Whosoever puts his trust in Allah, Allah suffices him.) (At-Talaq 65 : 3)
never forget to say the Du`aa’ taught by the Prophet when venturing out into the world of temptations: Here are the two main Du`aas we are required to recite while venturing out. They will definitely prove to be tremendous source of spiritual empowerment for believers in all walks of life:
Bismillaahi tawakkaltu `ala Allaah, laa hawla walaa quwwata illaa bilaah (In the name of Allah, I place all my trust in Allah; there is no power to shun evil, nor strength to earn good except with Allah’s assistance).
Allaahumaa innee ‘a`udhu bika an adillaa aw udalaa aw azilla aw uzalla, aw ajhala or unjhala `alayya (O Allah, I certainly seek refuge in You from leading people astray or being led astray, from slipping up or being led to slip up, or acting foolishly or others acting foolishly towards me).”
the Prophet (peace and blessings be upon him) reminded us that by praying thus we become protected and empowered.