A 40-year-old Brooklyn man who swam into the ocean at Rockaway Beach , Queens , yesterday trying to save a teenage boy who was floundering in a violent current died of a heart attack , the authorities said .