Bay Area Rapid Transit, or BART (www.bart.gov , fares vary $3–10/one-way) to locals, is the Bay Area ’s late-coming answer to major metropolitan underground railways like Chicago’s L-train and New York’s subway system. Sadly, there’s only one arterial line through the City.
However, service directly from San Francisco International Airport into the City now runs daily, as does service to Oakland International Airport, the cities of Oakland  and Berkeley , plus many other East Bay  destinations.
BART connects to the CalTrain  system and SFO in Milbrae. See the website for route maps, schedules (BART usually runs on time), and fare information.
To buy tickets, use the vending machines found in every BART station. If you plan to ride more than once, you can “add money” to a single ticket. Then keep that ticket and reuse it for each ride.