While there is no specific age in which NBA players are told to retire, the average age in which they do retire is 36. Some players retire earlier due to injury, boredom, etc., while others retire later.
You do not need to play college basketball to be in the NBA. The NBA rule, as of 2010, states that you must be 19 years of age. While most players prefer to go to college, some choose to play overseas in other leagues until they turn 19.
Kareem Abdul-Jabbar played in the NBA for 20 years from 1969 to 1989. He was drafted by the Milwaukee Bucks in 1969 and was with the team until he was traded to the Los Angeles Lakers in 1975. He then played with the Lakers until his retirement in 1989.
Karl "The Mailman" Malone play 18 seasons with the Utah Jazz, and one final season with the LA Lakers, before retiring from the NBA. In addition to that, he played 3 seasons of college basketball with Louisina Tech, where he worked on staff after his retirement from the NBA.